diff --git a/superset/db_engine_specs/athena.py b/superset/db_engine_specs/athena.py index c62a2455f68..a3abfdf1097 100644 --- a/superset/db_engine_specs/athena.py +++ b/superset/db_engine_specs/athena.py @@ -36,6 +36,8 @@ class AthenaEngineSpec(BaseEngineSpec): engine_name = "Amazon Athena" allows_escaped_colons = False disable_ssh_tunneling = True + # Athena doesn't support IS true/false syntax, use = true/false instead + use_equality_for_boolean_filters = True _time_grain_expressions = { None: "{col}", diff --git a/tests/unit_tests/db_engine_specs/test_athena.py b/tests/unit_tests/db_engine_specs/test_athena.py index 8337bfd7a6b..9e571eceb21 100644 --- a/tests/unit_tests/db_engine_specs/test_athena.py +++ b/tests/unit_tests/db_engine_specs/test_athena.py @@ -87,3 +87,36 @@ def test_get_text_clause_with_colon() -> None: ) text_clause = AthenaEngineSpec.get_text_clause(query) assert text_clause.text == query + + +def test_handle_boolean_filter() -> None: + """ + Test that Athena uses equality operators for boolean filters instead of IS. + """ + from sqlalchemy import Boolean, Column + + from superset.db_engine_specs.athena import AthenaEngineSpec + + # Create a mock SQLAlchemy column + bool_col = Column("test_col", Boolean) + + # Test IS_TRUE filter - use actual FilterOperator values + from superset.utils.core import FilterOperator + + result_true = AthenaEngineSpec.handle_boolean_filter( + bool_col, FilterOperator.IS_TRUE, True + ) + # The result should be a equality comparison, not an IS comparison + assert ( + str(result_true.compile(compile_kwargs={"literal_binds": True})) + == "test_col = true" + ) + + # Test IS_FALSE filter + result_false = AthenaEngineSpec.handle_boolean_filter( + bool_col, FilterOperator.IS_FALSE, False + ) + assert ( + str(result_false.compile(compile_kwargs={"literal_binds": True})) + == "test_col = false" + )