bvolpato opened a new pull request, #27192:
URL: https://github.com/apache/datafusion/pull/27192

   > [!IMPORTANT]
   >
   > **Fork CI setup:** For pull requests from a fork to `main`, enable 
workflows in your fork's **Actions** tab before you push.
   > See the [fork CI setup 
guide](https://datafusion.apache.org/contributor-guide/#pull-requests-from-forks).
   
   ## Which issue does this PR close?
   
   No linked issue.
   
   ## Rationale for this change
   
   This valid left join fails after a Substrait round-trip, including when the 
input plan is optimized first:
   
   ```sql
   SELECT l.a, l.b, r.a AS ra
   FROM (VALUES (1, 1), (2, 3), (3, 3)) l(a, b)
   LEFT JOIN (VALUES (1), (2), (3)) r(a)
     ON r.a = l.a AND l.a = l.b
   ORDER BY l.a;
   ```
   
   The decoder treats `l.a = l.b` as a join key and later fails during 
`type_coercion`. In this reproducer, it tries to resolve `left.column2` against 
the right input, whose only field is `right.column1`. Both columns in `l.a = 
l.b` belong to the left input, so this comparison must remain a join filter.
   
   This AI-assisted PR is a draft pending author review.
   
   ## What changes are included in this PR?
   
   Use `find_valid_equijoin_key_pair` with both input schemas before extracting 
column equalities as join keys. This also normalizes reversed operands. Keep 
same-input comparisons as filters and preserve the existing handling of mixed 
null-equality conditions.
   
   ## What is the testing strategy for this PR?
   
   An execution regression round-trips both optimized and unoptimized plans and 
checks the resulting rows. The left row `(2, 3)` must survive with a NULL right 
value, even though the right input contains key `2`. Focused unit coverage 
checks same-input `IS NOT DISTINCT FROM` and reversed join keys.
   
   The execution regression fails before the fix and passes afterward. Passed 
the Substrait crate tests, formatting, all-target/all-feature Clippy, the 
extended workspace tests from `AGENTS.md`, and `dev/rust_lint.sh`. The SQL 
logic suite was rerun successfully after rebuilding its cached binary to use 
this worktree's path normalization.
   
   ## Are there any user-facing changes?
   
   Substrait joins with same-input column equalities decode and execute 
correctly while preserving outer-join semantics.
   


-- 
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]

Reply via email to