File tree Expand file tree Collapse file tree
datafusion/sqllogictest/test_files Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -941,6 +941,36 @@ WHERE t2.a > 3 OR t2.a IN (SELECT t3.x FROM t3 WHERE t2.b < 150)
941941----
9429424 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
945975statement ok
946976RESET datafusion.optimizer.prefer_hash_join;
You can’t perform that action at this time.
0 commit comments