LukaZdravic opened a new pull request, #59016: URL: https://github.com/apache/spark/pull/59016
### What changes were proposed in this pull request? ASOF JOIN `MATCH_CONDITION` now accepts operands that are, or contain, an empty struct (`STRUCT<>`). The operand check was "orderable and contains no empty struct". It is now only "orderable", the same rule `min_by` and `max_by` use for their ordering column. Now accepted (same type on both sides): `STRUCT<>`, `STRUCT<x: STRUCT<>>`, `ARRAY<STRUCT<>>`. An empty struct against a non-empty struct stays rejected. ### Why are the changes needed? The comparison operator already accepts these pairs: `named_struct() >= named_struct()` is `true`, because two empty structs are equal. ASOF rejected them with an error that says the operands must be orderable, but `STRUCT<>` is orderable. ### Does this PR introduce _any_ user-facing change? Yes. This query failed and now runs: ```sql SELECT * FROM VALUES (named_struct()) AS l(s) ASOF JOIN VALUES (named_struct()) AS r(s) MATCH_CONDITION (l.s >= r.s); -- before: [ASOF_JOIN_MATCH_CONDITION_INVALID_TYPE] ... Got: "STRUCT<>" and "STRUCT<>". ``` Two empty structs are equal, so `>=` and `<=` match, and `>` and `<` find no match. SQL ASOF JOIN is not in a released Spark version yet. ### How was this patch tested? Unit tests in `AsOfJoinMatchConditionTypesSuite` and `AsOfJoinSQLSuite` for the accepted and rejected type pairs. Execution tests in `AsOfJoinSortMergeSQLSuite` assert the matched row for all four operators, for: an empty struct, a struct with only an empty field, a struct with an empty field and an int field (column and tuple form), and arrays of empty structs. ### 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]
