giftig opened a new issue, #24055:
URL: https://github.com/apache/superset/issues/24055

   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:
   
   ```sql
   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
   
   (please complete the following information):
   
   - browser type and version: all
   - superset version: `2.1`
   - python version: `python --version`
   - node.js version: `node -v`
   - any feature flags active:
   
   ### Checklist
   
   Make sure to follow these steps before submitting your issue - thank you!
   
   - [x] I have checked the superset logs for python stacktraces and included 
it here as text if there are any.
   - [x] I have reproduced the issue with at least the latest released version 
of superset.
   - [x] I have checked the issue tracker for the same issue and I haven't 
found one similar.
   
   ### Additional context
   
   Add any other context about the problem here.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to