fix(parser): parse qualified columns in GROUP BY - #2504
Merged
manticore-projects merged 1 commit intoAug 25, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes parser ambiguity where qualified columns in GROUP BY lists could be misclassified as lambda expressions.
Changes:
- Replaces fixed-width lambda lookahead with explicit arrow matching.
- Adds qualified-column and lambda regression coverage.
- Adds JSON operator AST assertions.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Review summary |
|---|---|
src/test/java/net/sf/jsqlparser/statement/select/SelectTest.java |
Adds qualified-column and JSON regression tests. |
src/test/java/net/sf/jsqlparser/expression/LambdaExpressionTest.java |
Adds lambda AST assertions. |
src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt |
Updates lambda lookahead, but requires changes to preserve comma-separated PostgreSQL JSON expressions and add regression coverage. |
Suppressed comments (1)
src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt:8032
->is also the PostgreSQL JSON extraction operator (see thePrimaryExpressionJSON branch atJSqlParserCC.jjt:8424-8449). Because this alternative runs beforeExpression(), a valid list such asSELECT f(1, data->'key') FROM tis classified as aLambdaExpressionrather than aJsonExpression; the new JSON assertions only cover a first select item and do not exercise this comma-separated path. Please add a disambiguation that preserves JSON expressions here and a regression test.
LOOKAHEAD( RelObjectName() "->" ) expr=LambdaExpression()
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| LOOKAHEAD(2, {!interrupted} ) "," | ||
| ( | ||
| LOOKAHEAD( 7 ) expr=LambdaExpression() | ||
| LOOKAHEAD( RelObjectName() "->" ) expr=LambdaExpression() |
Contributor
|
Thank you much for fixing this, it was broken indeed (and I caused that myself). |
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.
Fixes #2485
Summary
Parenthesized fully qualified columns in a
GROUP BYlist could be parsed asa lambda expression after a comma.
The fixed
LOOKAHEAD(7)accepted the seven-token(sys.dual.dummy)prefixbefore verifying the required
->. This caused the parser to enterLambdaExpressionand fail at EOF.The lookahead now matches the explicit unparenthesized lambda form,
RelObjectName() "->". Parenthesized lambdas continue to be handled throughthe regular
Expression()path.Tests
Coverage includes:
GROUP BYregression from [BUG] JSQLParser Version 5.3.218: RDBMS Oracle: failing group by parsing #2485;->and->>AST assertions.Validation: