fix: INNER of a following INNER JOIN wrongly consumed as table source alias (#6711) - #6713
Open
CuriousLinYu wants to merge 2 commits into
Open
fix: INNER of a following INNER JOIN wrongly consumed as table source alias (#6711)#6713CuriousLinYu wants to merge 2 commits into
CuriousLinYu wants to merge 2 commits into
Conversation
|
lintyu seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
1 similar comment
|
lintyu seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
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 does this PR do?
Fixes #6711.
When a FROM clause contains a join followed by another
INNER JOIN:the
INNERtoken of the second join is silently consumed as the alias of the previous table source / join node, producing a corrupted AST:alias = "INNER"JOINAS INNER:Since the corrupted output is still accepted by the same parser, re-validation with the same parser cannot detect the semantic damage.
Root cause
SQLSelectParser.parseTableSourceRest()guardsLEFT/RIGHT/FULLagainst being consumed as a table-source alias when they actually start the next join (lookahead forJOIN/OUTER/ANTI/ARRAY/SEMI), butINNERwas missing from that lookahead group, so it fell through to the alias path.Fix
Add
case INNERwith the same lookahead asLEFT/RIGHT/FULL, soINNERis only treated as an alias when it is not followed byJOIN/OUTER/ANTI/ARRAY/SEMI. Fully symmetric with the existing handling; realINNERaliases (when not followed by a join keyword) keep working.SQLSelectParseris the shared base parser, so this affects all dialects that reuse it (mysql, odps, postgresql, ...) — not only odps as reported in the issue.Tests
New test class
Issue6711covering:INNER JOINfollowed byINNER JOIN(odps / mysql / postgresql) — asserts both join nodes areINNER_JOINwith null aliasesLEFT/RIGHT/FULL JOINfollowed byINNER JOININNER JOINsAS INNERINNER JOINregression guardVerified locally:
mvn -pl core testpasses with the full core module suite (1759 test classes, 0 failures, 0 errors).Before the fix, 5 of the 6 new tests fail on master (commit fa8dc99); after the fix all 6 pass.