Repository navigation
[SPARK-59627][SQL] Report INCOMPATIBLE_JOIN_TYPES for unsupported join types for ASOF JOIN - #58997
Draft
LukaZdravic wants to merge 3 commits into
Draft
LukaZdravic wants to merge 3 commits into
LukaZdravic wants to merge 3 commits into
Conversation
…n types before ASOF JOIN ASOF JOIN supports only INNER and LEFT OUTER. Other join types before ASOF (RIGHT, FULL, CROSS, LEFT SEMI, NATURAL) failed with a generic PARSE_SYNTAX_ERROR that did not name the bad type. The grammar now accepts any join type and a leading NATURAL before ASOF JOIN, and AstBuilder rejects the unsupported ones with INCOMPATIBLE_JOIN_TYPES, which names the pair. This mirrors how NATURAL CROSS JOIN is handled.
- Test every join type ASOF rejects: RIGHT [OUTER], FULL [OUTER], CROSS, [LEFT] SEMI, [LEFT] ANTI, NATURAL and NATURAL LEFT, plus the pipe syntax path and RIGHT ASOF JOIN with ASOF disabled. - Take the expected error positions from the SQL text, not hand counts. - Use the Seq(...).contains check shape that NEAREST BY and LATERAL use. - Remove the unused AsOfJoinType.supportedDisplay. - Name the error in the ASOF JOIN reference page. Co-authored-by: Isaac <no-reply@databricks.com>
…TERAL Put ASOF at the end of the join type in the grammar, so a typo such as `a RIGHT b` keeps the "missing 'JOIN'" hint. AstBuilder now finds ASOF by its keyword and rejects the forms the grammar newly accepts: ASOF without MATCH_CONDITION and MATCH_CONDITION without ASOF (syntax errors, as before) and ASOF with LATERAL (INCOMPATIBLE_JOIN_TYPES). Co-authored-by: Isaac <no-reply@databricks.com>
LukaZdravic
marked this pull request as draft
September 24, 2026 09:04
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
ASOF JOINsupports onlyINNERandLEFT [OUTER]. Other join types (RIGHT,FULL,CROSS,SEMI,ANTI),NATURAL, andLATERALfailed with a generic syntax error.Now the grammar accepts them, and
AstBuilderrejects them withINCOMPATIBLE_JOIN_TYPES, as it already does forNATURAL CROSS JOIN. No new error condition is added.The grammar puts
ASOFat the end of the join type. This keeps the "missing 'JOIN'" hint for typos in ordinary joins, such asSELECT * FROM a RIGHT b. The two extra forms this accepts (ASOF withoutMATCH_CONDITION, andMATCH_CONDITIONwithout ASOF) are still syntax errors.Why are the changes needed?
The old error did not say which join type is wrong.
Does this PR introduce any user-facing change?
Yes, only in error messages of the
ASOF JOIN:SELECT * FROM l RIGHT ASOF JOIN r MATCH_CONDITION (l.ts >= r.ts);
-- Before: [PARSE_SYNTAX_ERROR] Syntax error at or near 'ASOF': extra input 'ASOF'.
-- After: [INCOMPATIBLE_JOIN_TYPES] The join types ASOF and RIGHT OUTER are incompatible.
Also,
lateralafterASOF JOINis now read as the keyword, as in ordinary joins.How was this patch tested?
New
PlanParserSuitetests for each rejected form, for the "missing 'JOIN'" hint on every join type, and forasofas a table alias. Two new cases in thejoin-asof-grammar.sqlgolden file.Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code