Skip to content

Commit 335db42

Browse files
committed
add sqllogictest test for apache#21197.
1 parent e051e23 commit 335db42

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

‎datafusion/sqllogictest/test_files/sort_merge_join.slt‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,36 @@ WHERE t2.a > 3 OR t2.a IN (SELECT t3.x FROM t3 WHERE t2.b < 150)
941941
----
942942
4 101 1001
943943

944+
# Regression test for https://github.com/apache/datafusion/issues/21197
945+
# LeftMark join with cross-table join filter on non-nullable columns.
946+
# The OR forces a LeftMark join. The cross-table filter (t2_data <> t1_data)
947+
# becomes a join filter referencing both sides. At scale, unmatched rows in
948+
# the mark join produce null right-side indices, and fetch_right_columns_by_idxs
949+
# maps those to null values in columns the schema declares non-nullable,
950+
# causing RecordBatch::try_new to fail.
951+
query I
952+
WITH t1_sorted AS (
953+
SELECT value % 1000 as key, value as data
954+
FROM range(10000)
955+
ORDER BY key, data
956+
),
957+
t2_sorted AS (
958+
SELECT value % 1000 as key, value as data
959+
FROM range(100000)
960+
ORDER BY key, data
961+
)
962+
SELECT count(*)
963+
FROM t1_sorted
964+
WHERE t1_sorted.data < 0
965+
OR EXISTS (
966+
SELECT 1 FROM t2_sorted
967+
WHERE t2_sorted.key = t1_sorted.key
968+
AND t2_sorted.data <> t1_sorted.data
969+
AND t2_sorted.data % 100 = 0
970+
)
971+
----
972+
100
973+
944974
# Config reset
945975
statement ok
946976
RESET datafusion.optimizer.prefer_hash_join;

0 commit comments

Comments
 (0)