Skip to content

Commit 2887491

Browse files
authored
fix: set null_equals_null to false when convert_cross_join_to_inner_join (#11738)
1 parent 89677ae commit 2887491

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

datafusion/optimizer/src/push_down_filter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1127,7 +1127,7 @@ fn convert_cross_join_to_inner_join(cross_join: CrossJoin) -> Result<Join> {
11271127
on: vec![],
11281128
filter: None,
11291129
schema: DFSchemaRef::new(join_schema),
1130-
null_equals_null: true,
1130+
null_equals_null: false,
11311131
})
11321132
}
11331133

datafusion/sqllogictest/test_files/join.slt

+23-1
Original file line numberDiff line numberDiff line change
@@ -1108,4 +1108,26 @@ statement ok
11081108
DROP TABLE t0;
11091109

11101110
statement ok
1111-
DROP TABLE t1;
1111+
DROP TABLE t1;
1112+
1113+
# Test SQLancer issue: https://github.com/apache/datafusion/issues/11704
1114+
query II
1115+
WITH
1116+
t1 AS (SELECT NULL::int AS a),
1117+
t2 AS (SELECT NULL::int AS a)
1118+
SELECT * FROM
1119+
(SELECT * FROM t1 CROSS JOIN t2)
1120+
WHERE t1.a == t2.a
1121+
AND t1.a + t2.a IS NULL;
1122+
----
1123+
1124+
# Similar to above test case, but without the equality predicate
1125+
query II
1126+
WITH
1127+
t1 AS (SELECT NULL::int AS a),
1128+
t2 AS (SELECT NULL::int AS a)
1129+
SELECT * FROM
1130+
(SELECT * FROM t1 CROSS JOIN t2)
1131+
WHERE t1.a + t2.a IS NULL;
1132+
----
1133+
NULL NULL

0 commit comments

Comments
 (0)