Repository navigation
fix: accept trailing comma in from list - #2948
Merged
manticore-projects merged 4 commits intoNov 22, 2026
Merged
manticore-projects merged 4 commits into
manticore-projects merged 4 commits into
Conversation
manticore-projects
requested changes
Nov 21, 2026
Contributor
Author
|
Thanks for the review, I've guarded it on Dialect.SNOWFLAKE. It got me a bit curious to see if other dialects allow this. I found that DuckDB also accepts this (and is actually documented https://duckdb.org/docs/2.0/sql/dialect/friendly_sql#trailing-commas and more: before GROUP BY/ORDER BY and at the end of the statement), but there's no DuckDB dialect to guard on and I think i'll keep this PR to be snowflake only. Happy to follow up separately if you'd like it supported. I haven't seen anything for the other dialects but I might test it just to make sure |
Contributor
|
Thank you much! |
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: