LukaZdravic opened a new pull request, #58997:
URL: https://github.com/apache/spark/pull/58997
### What changes were proposed in this pull request?
`ASOF JOIN` accepts only `INNER` and `LEFT [OUTER]`. Any other join type
before `ASOF` (`RIGHT`, `FULL`, `CROSS`, `LEFT SEMI`, `NATURAL`) failed with a
generic `PARSE_SYNTAX_ERROR` that did not say which join type is not allowed.
This PR:
- Grammar (`SqlBaseParser.g4`): the ASOF alternative now uses `joinType`
(any type) with an optional leading `NATURAL`. The unused `asofJoinType` rule
is removed.
- `AstBuilder.withAsOfJoin`: rejects a join type other than `INNER`/`LEFT
OUTER`, and a leading `NATURAL`, with `INCOMPATIBLE_JOIN_TYPES` naming the pair.
This mirrors the existing `NATURAL CROSS JOIN` handling: the grammar accepts
it, and `AstBuilder` rejects it with the same `INCOMPATIBLE_JOIN_TYPES` error.
No new error class is added.
### Why are the changes needed?
The generic error did not tell the user which join type is unsupported. The
new error names it, for example "The join types ASOF and RIGHT OUTER are
incompatible." The set of valid ASOF join types is unchanged (`INNER`, `LEFT
OUTER`).
### Does this PR introduce _any_ user-facing change?
Yes. The error for an unsupported join type before `ASOF JOIN` changes. This
is within unreleased master; `ASOF JOIN` is not in a released version.
Before:
SELECT * FROM l RIGHT ASOF JOIN r MATCH_CONDITION (l.ts >= r.ts);
-- [PARSE_SYNTAX_ERROR] Syntax error at or near 'ASOF': extra input
'ASOF'.
After:
SELECT * FROM l RIGHT ASOF JOIN r MATCH_CONDITION (l.ts >= r.ts);
-- [INCOMPATIBLE_JOIN_TYPES] The join types ASOF and RIGHT OUTER are
incompatible. SQLSTATE: 42613
### How was this patch tested?
- New `PlanParserSuite` test "asof join - unsupported join types rejected":
checks `RIGHT`, `FULL`, `CROSS`, `LEFT SEMI`, and `NATURAL` before `ASOF` each
raise `INCOMPATIBLE_JOIN_TYPES` with the expected pair and error context.
- Regenerated golden files `join-asof-grammar.sql.out` (results and
analyzer-results); the five unsupported-type cases now show
`INCOMPATIBLE_JOIN_TYPES`.
### 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]