xiedeyantu opened a new pull request, #22370: URL: https://github.com/apache/datafusion/pull/22370
## Which issue does this PR close? - Closes #22369 . ## Rationale for this change This PR adds a logical optimizer rule for `INNER JOIN` predicates of the form `cond1 OR cond2 ...`, inspired by Calcite PR 4300. When each OR branch can be decomposed into hashjoin-capable equality predicates, DataFusion can rewrite the join into a `UNION ALL` of mutually exclusive inner joins. This allows each branch to be planned as a normal equijoin instead of leaving the full disjunction in the join filter. To preserve SQL correctness for nullable expressions, branch exclusivity is expressed with `IS NOT TRUE` rather than plain `NOT` or `<>`. ## What changes are included in this PR? - Add a new logical optimizer rule, `expand_join_or_predicate`. - Restrict the rewrite to `INNER JOIN`. - Only apply the rewrite when every OR branch consists entirely of hashjoin-capable equality predicates. - Rewrite eligible OR join predicates into mutually exclusive `UNION ALL` branches. - Preserve existing `join.on` keys when adding keys extracted from OR branches. - Preserve the original join output schema and qualifiers across the rewritten `Union`. - Update the optimizer rule reference documentation. - Add sqllogictest coverage for result correctness, including nullable cases. - Update `EXPLAIN VERBOSE` sqllogictest expectations for the new optimizer pass. - Fix a schema-resolution issue in `eliminate_cross_join` exposed by the new rewrite. ## Are these changes tested? Yes. Added sqllogictest coverage to verify that: - rows matching multiple OR branches still appear exactly once - nullable branch behavior remains correct when earlier predicates evaluate to `NULL` Validated with: `cargo test -p datafusion-optimizer expand_join_or_predicate --lib` `cargo test -p datafusion-sqllogictest --test sqllogictests -- join_only.slt explain.slt` ## Are there any user-facing changes? No public API changes are included in this PR. This change only affects logical optimization for eligible `INNER JOIN ... ON ... OR ...` queries. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
