jonahgao opened a new pull request, #11738: URL: https://github.com/apache/datafusion/pull/11738
## Which issue does this PR close? <!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123. --> Closes #11704. ## Rationale for this change Given an example query: ```sql CREATE TABLE t1(a INT) AS VALUES(NULL); CREATE TABLE t2(a INT) AS VALUES(NULL); SELECT * FROM (SELECT * FROM t1 CROSS JOIN t2) WHERE t1.a == t2.a AND t1.a + t2.a IS NULL; ``` The `push_down_filter` rule will convert the cross join into an inner join. ```sh | initial_logical_plan | Projection: t1.a, t2.a | | | Filter: t1.a = t2.a AND t1.a + t2.a IS NULL | | | Projection: t1.a, t2.a | | | CrossJoin: | | | TableScan: t1 | | | TableScan: t2 | | logical_plan after push_down_filter | Projection: t1.a, t2.a | | | Projection: t1.a, t2.a | | | Inner Join: Filter: t2.a = t1.a AND t1.a + t2.a IS NULL | | | TableScan: t1 | | | TableScan: t2 | | extract_equijoin_predicate | Inner Join: t1.a = t2.a Filter: t1.a + t2.a IS NULL | | | TableScan: t1 projection=[a] | | | TableScan: t2 projection=[a] | ``` `null_equals_null` is only valid for equijoins, and when applying the corresponding equality predicate to the cross join, null does not equal null. So we should set `null_equals_null` to false in order to convert the cross join to an equivalent equijoin. ## What changes are included in this PR? <!-- There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR. --> ## Are these changes tested? Yes ## Are there any user-facing changes? No -- 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: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org