LukaZdravic opened a new pull request, #59267:
URL: https://github.com/apache/spark/pull/59267

   ### What changes were proposed in this pull request?
   ASOF JOIN now accepts a column hidden by a nested `USING` join (like `d.k` 
below) in `MATCH_CONDITION`. Before, it only looked at the visible columns of 
each side. 
   `RetainsOriginalJoinOutput` now handles `AsOfJoin` like `Join`, so both 
analyzers build the same plan.
   
   ### Why are the changes needed?
   A regular join accepts this column, but ASOF JOIN rejected it.
   
   ```sql
   SELECT l.lts, r.rts
   FROM (VALUES (1, 10), (2, 20)) AS l(k, lts)
   ASOF JOIN ((VALUES (1, 5), (2, 15)) AS r(k, rts) JOIN (VALUES (1), (2)) AS 
d(k) USING (k))
     MATCH_CONDITION (l.lts >= d.k);
   ```
   
   Before: `ASOF_JOIN_MATCH_CONDITION_TABLE_REFERENCE` error.
   After: `(10, 15)` and `(20, 15)`.
   
   ### Does this PR introduce _any_ user-facing change?
   Yes, the query above now works. 
   
   ### How was this patch tested?
   New tests in `AsOfJoinSQLSuite` and `join-asof-semantics.sql`: a hidden 
column on each side, one in `ON`, and one case that must still fail. Without 
the fix, the new tests fail.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   Generated-by: Claude Code


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