Skip to content

fix(parser): parse qualified columns in GROUP BY - #2504

Merged
manticore-projects merged 1 commit into
JSQLParser:masterfrom
jianjindream:codex/fix-2485-oracle-group-by
Aug 25, 2026
Merged

fix(parser): parse qualified columns in GROUP BY#2504
manticore-projects merged 1 commit into
JSQLParser:masterfrom
jianjindream:codex/fix-2485-oracle-group-by

Conversation

@jianjindream

Copy link
Copy Markdown
Contributor

Fixes #2485

Summary

Parenthesized fully qualified columns in a GROUP BY list could be parsed as
a lambda expression after a comma.

The fixed LOOKAHEAD(7) accepted the seven-token (sys.dual.dummy) prefix
before verifying the required ->. This caused the parser to enter
LambdaExpression and fail at EOF.

The lookahead now matches the explicit unparenthesized lambda form,
RelObjectName() "->". Parenthesized lambdas continue to be handled through
the regular Expression() path.

Tests

Coverage includes:

Validation:

  • Gradle check with JDK 17
  • 4,920 tests, 0 failures

@jianjindream
jianjindream marked this pull request as ready for review August 23, 2026 15:24
Copilot AI lite review requested due to automatic review settings August 23, 2026 15:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 the PrimaryExpression JSON branch at JSqlParserCC.jjt:8424-8449). Because this alternative runs before Expression(), a valid list such as SELECT f(1, data->'key') FROM t is classified as a LambdaExpression rather than a JsonExpression; 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()
@manticore-projects

Copy link
Copy Markdown
Contributor

Thank you much for fixing this, it was broken indeed (and I caused that myself).

@manticore-projects
manticore-projects merged commit dff722b into JSQLParser:master Aug 25, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] JSQLParser Version 5.3.218: RDBMS Oracle: failing group by parsing

3 participants