questdb / questdb-connect

SQLAchemy and Apache Superset extensions for QuestDB
Apache License 2.0
14 stars 6 forks source link

fix: fix compatibility with superset #18

Closed ideoma closed 3 months ago

ideoma commented 3 months ago

Apache Superset creates SQLAlchemy engine with future=False flag and it breaks QuestDB query execution with error


superset_app          | 2024-08-14 14:52:50,753:INFO:superset.commands.sql_lab.execute:Triggering query_id: 133
superset_app          | 2024-08-14 14:52:50,759:DEBUG:superset.sql_parse:Parsing with sqlparse statement: select * from btc_trades;
superset_app          | 2024-08-14 14:52:50,760:DEBUG:superset.sql_parse:Parsing with sqlparse statement: select * from btc_trades
superset_app          | 2024-08-14 14:52:50,765:DEBUG:celery.utils.functional:
superset_app          | def get_sql_results(query_id, rendered_query, return_results=0, store_results=1, username=2, start_time=3, expand_data=4, log_params=5):
superset_app          |     return 1
superset_app          |
superset_app          | 2024-08-14 14:52:50,773:DEBUG:superset.sql_parse:Parsing with sqlparse statement: select * from btc_trades
superset_app          | 2024-08-14 14:52:50,773:INFO:superset.sql_lab:Query 133: Executing 1 statement(s)
superset_app          | 2024-08-14 14:52:50,773:INFO:superset.sql_lab:Query 133: Set query to 'running'
superset_app          | 2024-08-14 14:52:50,779:DEBUG:superset.models.core:Database._get_sqla_engine(). Masked URL: questdb://admin:XXXXXXXXXX@host.docker.internal:8812/qdb
superset_app          | 2024-08-14 14:52:50,793:INFO:superset.sql_lab:Query 133: Running statement 1 out of 1
superset_app          | 2024-08-14 14:52:50,797:DEBUG:superset.sql_parse:Parsing with sqlparse statement: select * from btc_trades
superset_app          | 2024-08-14 14:52:50,798:DEBUG:superset.sql_parse:Parsing with sqlparse statement: select * from btc_trades
superset_app          | 2024-08-14 14:52:50,801:DEBUG:root:Query 133: Running query: select * from btc_trades
superset_app          | LIMIT 1001
superset_app          | 2024-08-14 14:52:50,801:DEBUG:superset.stats_logger:[stats_logger] (timing) sqllab.query.time_executing_query | 1.43115234375
superset_app          | 2024-08-14 14:52:50,802:DEBUG:superset.sql_lab:Query 133: Boolean value of this clause is not defined
superset_app          | 2024-08-14 14:52:50,812:DEBUG:superset.stats_logger:[stats_logger] (incr) SqlLabRestApi.execute_sql_query.error
superset_app          | 2024-08-14 14:52:50,812:WARNING:superset.views.base:SupersetErrorsException
superset_app          | Traceback (most recent call last):
superset_app          |   File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1823, in full_dispatch_request
superset_app          |     rv = self.dispatch_request()
superset_app          |   File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1799, in dispatch_request
superset_app          |     return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
superset_app          |   File "/usr/local/lib/python3.9/site-packages/flask_appbuilder/security/decorators.py", line 95, in wraps
superset_app          |     return f(self, *args, **kwargs)
superset_app          |   File "/app/superset/views/base_api.py", line 127, in wraps
superset_app          |     raise ex
superset_app          |   File "/app/superset/views/base_api.py", line 121, in wraps
superset_app          |     duration, response = time_function(f, self, *args, **kwargs)
superset_app          |   File "/app/superset/utils/core.py", line 1463, in time_function
superset_app          |     response = func(*args, **kwargs)
superset_app          |   File "/app/superset/views/base_api.py", line 93, in wraps
superset_app          |     return f(self, *args, **kwargs)
superset_app          |   File "/app/superset/utils/log.py", line 255, in wrapper
superset_app          |     value = f(*args, **kwargs)
superset_app          |   File "/app/superset/sqllab/api.py", line 409, in execute_sql_query
superset_app          |     command_result: CommandResult = command.run()
superset_app          |   File "/app/superset/commands/sql_lab/execute.py", line 121, in run
superset_app          |     raise ex
superset_app          |   File "/app/superset/commands/sql_lab/execute.py", line 103, in run
superset_app          |     status = self._run_sql_json_exec_from_scratch()
superset_app          |   File "/app/superset/commands/sql_lab/execute.py", line 163, in _run_sql_json_exec_from_scratch
superset_app          |     raise ex
superset_app          |   File "/app/superset/commands/sql_lab/execute.py", line 158, in _run_sql_json_exec_from_scratch
superset_app          |     return self._sql_json_executor.execute(
superset_app          |   File "/app/superset/sqllab/sql_json_executer.py", line 111, in execute
superset_app          |     raise SupersetErrorsException(
superset_app          | superset.exceptions.SupersetErrorsException: [SupersetError(message='questdb error: Boolean value of this clause is not defined', error_type=<SupersetErrorType.GENERIC_DB_ENGINE_ERROR: 'GENERIC_DB_ENGINE_ERROR'>, level=<ErrorLevel.ERROR: 'error'>, extra={'engine_name': 'QuestDB', 'issue_codes': [{'code': 1002, 'message': 'Issue 1002 - The database returned an unexpected error.'}]})]

This PR creates SQLAlchemy engine with Future=False flag in superset tests and fixes the execution.