FrancescoCastaldi commented on PR #44355:
URL: https://github.com/apache/superset/pull/44355#issuecomment-5888145353

   @rusackas You're right — the flag alone only changes the adhoc `IS TRUE`/`IS 
FALSE` path, and the native-filter `IN` clause would still hit 
`DATATYPE_MISMATCH`. Digging into the values side, the problem is that the 
Hive/Databricks SQLAlchemy dialects render Python `True`/`False` as integer 
literals when binding parameters (pyhive's `escape_item` treats booleans as 
numbers, so `False` binds as `0`), which is how `is_test_user IN (0)` reaches 
the warehouse in the first place.
   
   aeb3031 addresses the native path and the comparison operators:
   
   - New `coerce_boolean_for_sql` hook on `BaseEngineSpec` (identity by 
default), overridden on `DatabricksBaseEngineSpec`, `DatabricksHiveEngineSpec` 
and `SparkEngineSpec` to emit SQLAlchemy `true()`/`false()` — those compile to 
the `TRUE`/`FALSE` keywords and never reach the driver as bind parameters, so 
there is nothing left for the driver to misrender.
   - `filter_values_handler` in `helpers.py` now runs boolean filter values 
through the hook, so native-filter `IN`/`NOT IN` and `EQUALS`/`NOT_EQUALS` on 
boolean columns compile as `col IN (true, false)` / `col = true` — the exact 
repro in #36765.
   - `handle_boolean_filter` uses the same coercion, keeping the adhoc path on 
equality against boolean keywords.
   
   Tests assert the compiled SQL, not just the Python expressions: 
`filter_values_handler` IN-list coercion with empty bind params in 
`tests/unit_tests/models/helpers_test.py`, and spec-level coercion plus 
`handle_boolean_filter` compilation in 
`tests/unit_tests/db_engine_specs/test_databricks.py` (78 passed locally).
   
   Also rebased on master — the Databricks driver reorganization and #44286 
landed in the meantime, so the branch is current again.
   


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