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

   ### What changes were proposed in this pull request?
   `Dataset.joinAsOf` with `usingColumns` now builds an `AsOfJoin` with 
`usingColumns` set, the same node that SQL `ASOF JOIN ... USING` builds. Both 
analyzers already expand it, so the output has one column per name, placed 
first, as in SQL.
   It used to turn each name into `left(name) === right(name)`, which kept the 
key of both sides.
   Spark Connect and PySpark `_joinAsOf` call `Dataset.joinAsOf`, so they 
change too. A migration guide line is added.
   
   ```
   joinAsOf(quotes, ts, ts, usingColumns = Seq("sym"))
   before: ts, sym, qty, ts, sym, bid   (select("sym") fails with 
AMBIGUOUS_REFERENCE)
   after:  sym, ts, qty, ts, bid        (same as SQL ASOF JOIN quotes ... USING 
(sym))
   ```
   
   ### Why are the changes needed?
   The DataFrame API and SQL gave different columns for the same join, and the 
key could not be selected by name.
   
   ### Does this PR introduce _any_ user-facing change?
   Yes, for the private DataFrame as-of join (`DataFrame._joinAsOf` in PySpark, 
and Spark Connect) when `on` is a column name or a list of names. The output 
has one key column per name instead of two. There is no switch for the old 
output. The key keeps the type of the left side, and names are matched against 
top-level columns as in a regular USING join (a nested, quoted or metadata name 
now fails). A join with a Column for `on`, and `pandas.merge_asof`, are not 
changed.
   
   ### How was this patch tested?
   - `DataFrameAsOfJoinSuite`: columns, schema and rows equal SQL `ASOF JOIN 
... USING` for INNER and LEFT, one and two keys. Also select/filter/group by 
the key, an unmatched LEFT row and a NULL key, a self join, a missing name 
(`UNRESOLVED_USING_COLUMN_FOR_JOIN`), tolerance and direction against the rows 
of the Column-condition join. Each test runs with the fixed-point and 
single-pass analyzers, the sort-merge flag off and on, and ANSI on and off.
   - Also: qualified access to the right key, INT vs BIGINT and STRING keys 
against SQL USING, case sensitivity, a nested field name.
   - `SparkConnectProtoSuite`: a Connect as-of join with `using_columns` 
returns one key column, resolves plan-id keys with rows, with both analyzers.
   - `StreamingAsOfJoinSuite`: a stream-static DataFrame join with using 
columns.
   - Existing ASOF, join and codegen suites, with expected rows updated for the 
new column order.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   Generated-by: Claude Code
   
   This pull request and its description were written by Isaac.
   


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