abilian / olapy

OlaPy, an experimental OLAP engine based on Pandas
GNU Lesser General Public License v2.1
103 stars 19 forks source link

MDX parsing? #38

Open alexaurea opened 2 years ago

alexaurea commented 2 years ago

I'm trying to create a simple MDX example using a db backend, but I'm constantly getting "NoneType" is not ..... and the reason seams (at least on first sight) that olapy can't parse the query properly. (See the screenshot of a debug session).

The query is rather simple:

database_uri_with_no_db = f"postgresql+psycopg2://{config.DB_USER}:{config.DB_PASSWORD}@{config.DB_HOST}:{config.DB_PORT}"
os.environ["SQLALCHEMY_DATABASE_URI "] = database_uri_with_no_db
executor = MdxEngine(source_type="db", sqla_engine=db_engine, cube="accounts")
query = """
SELECT
    { [amount] }  ON COLUMNS,
    { [account]  }  ON ROWS
FROM {accounts}
"""
df = executor.execute_mdx(query)['result']

What am I doing incorrectly?

image

(The actual error I'm getting when running the example is

Traceback (most recent call last):
  File "W:\src\exampple\mdx.py", line 18, in <module>
    df = executor.execute_mdx(query)['result']
  File "C:\Python39\lib\site-packages\olapy\core\mdx\executor\execute.py", line 799, in execute_mdx
    self.star_schema_dataframe[self.selected_measures].sum().to_frame().T
TypeError: 'NoneType' object is not subscriptable