Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preview table query fails for trino tables with date partition #24055

Closed
3 tasks done
giftig opened this issue May 15, 2023 · 2 comments
Closed
3 tasks done

Preview table query fails for trino tables with date partition #24055

giftig opened this issue May 15, 2023 · 2 comments
Labels
#bug Bug report

Comments

@giftig
Copy link
Contributor

giftig commented May 15, 2023

An error is seen on the frontend as a result of running the preview table query in SQL Lab; this appears to be a regression in 2.1. The error reads:

Cannot apply operator: date = varchar(10)

and the underlying query looks like:

SELECT (redacted fields),
              ...,
              date
FROM my_schema.my_table
WHERE date = '2023-04-17'
LIMIT 100

This is due to comparing text with a date field here, as the query should read WHERE date = DATE '2023-04-17' instead.

How to reproduce the bug

  1. Connect a trino database with a table partitioned on a DATE column
  2. Go to SQL Lab
  3. Select the appropriate database, schema, and table
  4. See preview query run and result in the above error

Expected results

The preview should provide an actual preview of the table

Actual results

The above error. Full stacktrace here:

superset.exceptions.SupersetErrorsException: [SupersetError(message='trino error: line 11:12: Cannot apply operator: date = varchar(10)', error_type=<SupersetErrorType.GENERIC_DB_ENGINE_ERROR: 'GENERIC_DB_ENGINE_ERROR'>, level=<ErrorLevel.ERROR: 'error'>, extra={'engine_name': 'Trino', 'issue_codes': [{'code': 1002, 'message': 'Issue 1002 - The database returned an unexpected error.'}]})]
2023-05-11 14:44:29,745:WARNING:superset.views.base:SupersetErrorsException
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1517, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1503, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/usr/local/lib/python3.8/site-packages/flask_appbuilder/security/decorators.py", line 95, in wraps
    return f(self, *args, **kwargs)
  File "/opt/superset/superset/views/base_api.py", line 122, in wraps
    raise ex
  File "/opt/superset/superset/views/base_api.py", line 113, in wraps
    duration, response = time_function(f, self, *args, **kwargs)
  File "/opt/superset/superset/utils/core.py", line 1586, in time_function
    response = func(*args, **kwargs)
  File "/opt/superset/superset/views/base_api.py", line 85, in wraps
    return f(self, *args, **kwargs)
  File "/opt/superset/superset/utils/log.py", line 266, in wrapper
    value = f(*args, **kwargs)
  File "/opt/superset/superset/sqllab/api.py", line 256, in execute_sql_query
    command_result: CommandResult = command.run()
  File "/opt/superset/superset/sqllab/commands/execute.py", line 121, in run
    raise ex
  File "/opt/superset/superset/sqllab/commands/execute.py", line 103, in run
    status = self._run_sql_json_exec_from_scratch()
  File "/opt/superset/superset/sqllab/commands/execute.py", line 162, in _run_sql_json_exec_from_scratch
    raise ex
  File "/opt/superset/superset/sqllab/commands/execute.py", line 157, in _run_sql_json_exec_from_scratch
    return self._sql_json_executor.execute(
  File "/opt/superset/superset/sqllab/sql_json_executer.py", line 111, in execute
    raise SupersetErrorsException(
superset.exceptions.SupersetErrorsException: [SupersetError(message='trino error: line 11:12: Cannot apply operator: date = varchar(10)', error_type=<SupersetErrorType.GENERIC_DB_ENGINE_ERROR: 'GENERIC_DB_ENGINE_ERROR'>, level=<ErrorLevel.ERROR: 'error'>, extra={'engine_name': 'Trino', 'issue_codes': [{'code': 1002, 'message': 'Issue 1002 - The database returned an unexpected error.'}]})]

Note that the error is somewhat difficult to trace from this alone, as the frontend gets the query from one endpoint, where it's provided as selectStar, and comes from the DB engine spec, and then posts that SQL to the normal run SQL endpoint, which is where the above stack trace occurs.

Environment

  • browser type and version: all (backend bug)
  • superset version: 2.1
  • python version: 3.8.13
  • node.js version: N/A
  • any feature flags active: defaults

Checklist

Make sure to follow these steps before submitting your issue - thank you!

  • I have checked the superset logs for python stacktraces and included it here as text if there are any.
  • I have reproduced the issue with at least the latest released version of superset.
  • I have checked the issue tracker for the same issue and I haven't found one similar.
@giftig
Copy link
Contributor Author

giftig commented May 15, 2023

@rusackas
Copy link
Member

Assuming this was resolved by the linked PR. If not, feel free to re-open and update context as warranted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
#bug Bug report
Projects
None yet
Development

No branches or pull requests

2 participants