Repository navigation
fix: accept trailing comma in from list - #2948
Open
harryfoster2006 wants to merge 1 commit into
Open
harryfoster2006 wants to merge 1 commit into
harryfoster2006 wants to merge 1 commit into
Conversation
manticore-projects
requested changes
Nov 21, 2026
| [ LOOKAHEAD(2) lateralViews=LateralViews() ] | ||
| [ LOOKAHEAD(2) joins=JoinsList() ] | ||
| // trailing comma after the last table: FROM a, b, WHERE ... | ||
| [ LOOKAHEAD({ isTrailingFromItemCommaAhead() }) "," ] |
Contributor
There was a problem hiding this comment.
You will need to guard this by supporting/affected Dialect please.
Contributor
There was a problem hiding this comment.
Also, please provide at least one test where the Validation fails when other or no Dialects are selected.
| [ LOOKAHEAD(3) <K_FROM> <K_ONLY> { plainSelect.setUsingOnly(true); } fromItem=FromItem() | ||
| [ LOOKAHEAD(2) lateralViews=LateralViews() ] | ||
| [ LOOKAHEAD(2) joins=JoinsList() ] | ||
| [ LOOKAHEAD({ isTrailingFromItemCommaAhead() }) "," ] |
Contributor
There was a problem hiding this comment.
You will need to guard this by supporting/affected Dialect please.
| } | ||
|
|
||
| @Test | ||
| void testTrailingCommaInFromListBeforeWhere() throws JSQLParserException { |
Contributor
There was a problem hiding this comment.
Please use parametrized tests.
| } | ||
|
|
||
| @Test | ||
| void testTrailingCommaInFromListOnlyBeforeWhere() { |
Contributor
There was a problem hiding this comment.
Please use parametrized tests.
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.
Snowflake accepts a trailing comma after the last table of a comma-separated FROM list. This isn't in the Snowflake documentation, but running these by hand on Snowflake works and we have seen real cases:
Current behaviour: JSqlParser already accepts the select-list comma but fails on the
,beforeWHERE.Fix
PlainSelect now takes one optional
,after FromItem, LateralViews and JoinsList, for bothFROMandFROM ONLY.Scope: a new semantic lookahead,
isTrailingFromItemCommaAhead(), only matches when the next token is,and the one after it isWHERE, so it doesn't change how any other comma is parsed.Result: the comma is dropped rather than kept as an empty join.
SELECT * FROM a, b, WHERE 1 = 1has a single join b and deparses toSELECT * FROM a, b WHERE 1 = 1SELECT * FROM a, WHERE 1 = 1has no joins at allTests: