greg-om opened a new issue, #45481:
URL: https://github.com/apache/superset/issues/45481

   ### Bug description
   
   Filtering on a TINYINT column fails on engines that use the default column 
type mappings, such as Amazon Athena. Superset sends the filter value as a 
quoted string, so engines with strict typing reject the query.
   
   BaseEngineSpec._default_column_type_mappings has entries for SMALLINT, 
INT/INTEGER and BIGINT, but not for TINYINT. A TINYINT column therefore gets 
type_generic: null. In filter_values_handler the column is treated as 
GenericDataType.STRING, cast_to_num is skipped, and the value is bound as a 
string literal.
   
   Steps to reproduce:
   1. Connect an Amazon Athena database. Register a dataset on a table with a 
tinyint column, e.g. flag tinyint.
   2. Call GET /api/v1/dataset/<id>. The column shows "type": "TINYINT" and 
"type_generic": null.
   3. Create any chart, e.g. a line chart, and add a simple filter flag >= 2.
   4. Run the chart.
   
   The generated SQL is:
   
   WHERE flag >= '2'
   
   and Athena returns:
   
   TYPE_MISMATCH: line 12:29: Cannot apply operator: tinyint <= varchar(1)
   
   Expected: TINYINT is treated as NUMERIC like the other integer types, 
type_generic is 0, and the filter compiles to WHERE flag >= 2.
   
   Suggested fix: add (re.compile(r"^tinyint", re.IGNORECASE), 
types.SmallInteger(), GenericDataType.NUMERIC) to 
_default_column_type_mappings, next to ^smallint. With that mapping, the query 
above runs successfully on Athena.
   
   ### Screenshots/recordings
   
   _No response_
   
   ### Superset version
   
   6.1.0
   
   ### Python version
   
   3.11
   
   ### Node version
   
   18 or greater
   
   ### Browser
   
   Chrome
   
   ### Additional context
   
   _No response_
   
   ### Checklist
   
   - [x] I have searched Superset docs and Slack and didn't find a solution to 
my problem.
   - [x] I have searched the GitHub issue tracker and didn't find a similar bug 
report.
   - [x] I have checked Superset's logs for errors and if I found a relevant 
Python stacktrace, I included it here as text in the "additional context" 
section.


-- 
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