bito-code-review[bot] commented on code in PR #36777:
URL: https://github.com/apache/superset/pull/36777#discussion_r2637297546
##########
tests/integration_tests/db_engine_specs/databricks_tests.py:
##########
@@ -59,3 +61,44 @@ def test_extras_with_ssl_custom(self):
extras = DatabricksNativeEngineSpec.get_extra_params(database)
connect_args = extras["engine_params"]["connect_args"]
assert connect_args["ssl"] == "1"
+
+ def test_handle_boolean_in_clause(self):
+ """
+ Test that boolean IN clauses use boolean literals instead of integers.
+
+ Databricks requires boolean literals (True/False) in IN clauses,
+ not integers (0/1). This test verifies that handle_boolean_in_clause
+ converts values properly and uses OR conditions with equality checks.
+ """
+ # Create a mock table with a boolean column
+ test_table = Table(
+ "test_table",
+ mock.MagicMock(),
+ Column("is_test_user", Boolean),
+ )
+ sqla_col = test_table.c.is_test_user
+
+ # Test with boolean values
+ result = DatabricksNativeEngineSpec.handle_boolean_in_clause(
+ sqla_col, [False]
+ )
+ # Verify the result is an OR condition (not an IN clause)
+ assert result is not None
+
+ # Test with integer values (should be converted to booleans)
+ result = DatabricksNativeEngineSpec.handle_boolean_in_clause(
+ sqla_col, [0, 1]
+ )
+ assert result is not None
+
+ # Test with string values
+ result = DatabricksNativeEngineSpec.handle_boolean_in_clause(
+ sqla_col, ["false", "true"]
+ )
+ assert result is not None
+
+ # Test with empty list (should return false condition)
+ from sqlalchemy import false
+ result = DatabricksNativeEngineSpec.handle_boolean_in_clause(sqla_col,
[])
+ # The result should be a false condition when all values are filtered
out
+ assert result is not None
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Weak test assertions</b></div>
<div id="fix">
The test_handle_boolean_in_clause method has weak assertions that only check
result is not None, which won't catch bugs in the method's expression
generation. The comment claiming an OR condition for single values is
inaccurate. Consider using real SQLAlchemy MetaData and adding edge case
testing for None inputs.
</div>
</div>
<small><i>Code Review Run #cfb8d0</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
--
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]