rusackas commented on code in PR #41867:
URL: https://github.com/apache/superset/pull/41867#discussion_r3681134904


##########
tests/unit_tests/db_engine_specs/test_clickhouse.py:
##########
@@ -562,3 +562,43 @@ def run(sql: str) -> str:
     with pytest.raises(Exception, match="TOO_MANY_ROWS"):
         database.run_with_sampling_read_limit_retry("SELECT 1", run)
     assert executed == ["SELECT 1"]
+
+
+def test_handle_boolean_filter() -> None:
+    """
+    Test that ClickHouse uses equality operators for boolean filters instead 
of IS.
+
+    ClickHouse rejects the ``column IS true/false`` form, so boolean filters 
must
+    render as ``column = true/false``.
+    """
+    from sqlalchemy import Boolean, Column
+
+    from superset.db_engine_specs.clickhouse import ClickHouseBaseEngineSpec
+    from superset.utils.core import FilterOperator
+
+    bool_col = Column("test_col", Boolean)
+
+    result_true = ClickHouseBaseEngineSpec.handle_boolean_filter(
+        bool_col, FilterOperator.IS_TRUE, True
+    )
+    assert (
+        str(result_true.compile(compile_kwargs={"literal_binds": True}))
+        == "test_col = true"
+    )
+
+    result_false = ClickHouseBaseEngineSpec.handle_boolean_filter(
+        bool_col, FilterOperator.IS_FALSE, False
+    )
+    assert (
+        str(result_false.compile(compile_kwargs={"literal_binds": True}))
+        == "test_col = false"
+    )

Review Comment:
   handle_boolean_filter just returns a plain SQLAlchemy `==` expression, so 
which concrete engine spec calls it doesn't change the rendering, and 
clickhouse-connect/clickhouse-sqlalchemy aren't even test/CI dependencies here 
to compile against a real ClickHouse dialect. But the computed-expression case 
is a fair ask, so I added one matching what Presto/Trino already do for this 
same toggle (`(is_cancelled = 1)`) in 15f0954.



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