marc nicole
marc nicole

Reputation: 83

Unexpected error thrown when drill down a cube using cubes library

I encounter an issue with code posted at the aforementioned link: https://pythonhosted.org/cubes/tutorial.html

Specifically, the error states:

AttributeError: 'Subquery' object has no attribute 'count'
at line : `result = browser.aggregate(cell, drilldown={"item":"subcategory", "year":None})`

Specs are: SQLAlchemy version is 1.4.4, Python 3.9 cubes v1.1. Does this sound familiar?

Thanks

PS: code I use is the following:

engine = create_engine('sqlite:///data.sqlite')
create_table_from_csv(engine,
                         "../data/data.csv",
                         table_name="irbd_balance",
                         fields=[
                            ("category", "string"),
                            ("category_label", "string"),
                             ("subcategory", "string"),
                              ("subcategory_label", "string"),
                              ("line_item", "string"),
                             ("year", "integer"),
                             ("amount", "integer")],
                        create_id=True
                  )
print("done. file data.sqlite created")
workspace = Workspace()
workspace.register_default_store("sql", url="sqlite:///data.sqlite")
workspace.import_model("../model.json")
cube = workspace.cube("irbd_balance")
full_cube = Cell(cube)
result = browser.aggregate(full_cube, drilldown=["item"])#error here throwing: AttributeError: 'Subquery' object has no attribute 'count'

for record in result.drilldown:
   print(record)

UPDATE: Full stacktrace:

Stacktrace is:

Traceback (most recent call last):
  File "C:\Users\path\tests\test_cube.py", line 60, in <module>
    result = browser.aggregate(cell, drilldown=["item"])
  File "C:\Users\path\venv\lib\site-packages\cubes\browser.py", line 145, in aggregate
    result = self.provide_aggregate(cell,
  File "C:\Users\path\venv\lib\site-packages\cubes\sql\browser.py", line 437, in provide_aggregate
    count_statement = statement.alias().count()
AttributeError: 'Subquery' object has no attribute 'count'

Upvotes: 0

Views: 46

Answers (0)

Related Questions