Skip to content

Commit 839ca05

Browse files
morningmanclaude
andcommitted
[test](jdbc) Assert SQL Server bit IN pushdown form and make filter checks selective
Address review on apache#64464: the previous `bit_value in ('1', '0')` check matched every non-null row and asserted nothing, so it would pass even if the IN predicate were dropped. Add an explain assertion that the pushed remote SQL renders the IN with integer literals ([bit_value] IN (1, 0)), and replace the non-asserting executions with selective order_qt cases (`= '0'` -> id=1, `= '1'` -> id=2,3) that fail if the filter is not applied. Related apache#64464 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
1 parent 2c89bdf commit 839ca05

2 files changed

Lines changed: 28 additions & 9 deletions

File tree

‎regression-test/data/external_table_p0/jdbc/test_sqlserver_jdbc_catalog.out‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,18 @@ varbinary_value varbinary(20) Yes true \N
184184
2 true 0x4D616B6520446F72697320477265617421000000 0x4D616B6520446F72697320477265617421
185185
3 true 0x4D616B6520446F72697320477265617421000000 0x4D616B6520446F72697320477265617421
186186

187+
-- !bit_eq_false --
188+
1 false
189+
190+
-- !bit_eq_true --
191+
2 true
192+
3 true
193+
194+
-- !bit_in --
195+
1 false
196+
2 true
197+
3 true
198+
187199
-- !query_after_insert --
188200
1 false 0x4D616B6520446F72697320477265617421000000 0x4D616B6520446F72697320477265617421
189201
2 true 0x4D616B6520446F72697320477265617421000000 0x4D616B6520446F72697320477265617421

‎regression-test/suites/external_table_p0/jdbc/test_sqlserver_jdbc_catalog.groovy‎

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,10 @@ suite("test_sqlserver_jdbc_catalog", "p0,external,sqlserver,external_docker,exte
142142

143143
// Regression test for https://github.com/apache/doris/issues/64464
144144
// SQL Server `bit` maps to Doris BOOLEAN, so a predicate like `bit_value = '1'`
145-
// is folded to a boolean literal during analysis. When the filter is pushed down
146-
// it must be rendered as an integer (`= 1` / `= 0`) for SQL Server, never the
147-
// `TRUE`/`FALSE` keyword: SQL Server has no boolean literal and would otherwise
148-
// report "Invalid column name 'TRUE'".
145+
// is folded to a boolean literal during analysis. When the filter is pushed down it
146+
// must be rendered with integer literals (`= 1` / `= 0` / `IN (1, 0)`) for SQL Server,
147+
// never the `TRUE`/`FALSE` keyword: SQL Server has no boolean literal and would
148+
// otherwise report "Invalid column name 'TRUE'".
149149
explain {
150150
sql("select * from test_binary where bit_value = '1'")
151151
contains "[bit_value] = 1"
@@ -154,11 +154,18 @@ suite("test_sqlserver_jdbc_catalog", "p0,external,sqlserver,external_docker,exte
154154
sql("select * from test_binary where bit_value = '0'")
155155
contains "[bit_value] = 0"
156156
}
157-
// Execute the predicates end-to-end; on the buggy path these throw
158-
// "Invalid column name 'TRUE'" against SQL Server.
159-
sql """ select * from test_binary where bit_value = '1' order by id; """
160-
sql """ select * from test_binary where bit_value = '0' order by id; """
161-
sql """ select * from test_binary where bit_value in ('1', '0') order by id; """
157+
explain {
158+
sql("select * from test_binary where bit_value in ('1', '0')")
159+
contains "[bit_value] IN (1, 0)"
160+
}
161+
// Selective execution checks. At this point test_binary holds id=1 (bit 0),
162+
// id=2 and id=3 (bit 1), so `= '0'` returns only id=1 and `= '1'` only id=2,3:
163+
// these fail if the pushed-down filter is dropped or applied as a no-op. The IN
164+
// predicate matches every row (a bit is always 0 or 1), so its 1/0 rendering is
165+
// asserted by the explain above rather than by row selectivity.
166+
order_qt_bit_eq_false """ select id, bit_value from test_binary where bit_value = '0' order by id; """
167+
order_qt_bit_eq_true """ select id, bit_value from test_binary where bit_value = '1' order by id; """
168+
order_qt_bit_in """ select id, bit_value from test_binary where bit_value in ('1', '0') order by id; """
162169

163170
sql """ insert into test_binary values (4, 4, X"ABAB", X"AB") """
164171
order_qt_query_after_insert """ select * from test_binary order by id; """

0 commit comments

Comments
 (0)