fix: support ClickHouse tuple positional access - #2454
Merged
manticore-projects merged 1 commit intoAug 8, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes ClickHouse parsing for tuple positional access syntax tuple(...).N by handling the lexer’s S_DOUBLE tokenization of .2 within the InternalFunction postfix grammar, and adds a regression test to ensure round-trip parse/deparse stability.
Changes:
- Extend
InternalFunctionpostfix parsing to accept strictS_DOUBLEtokens matching.[0-9]+and map them to aLongValuefunction attribute. - Preserve existing
.+Function()/Column()postfix behavior for non-numeric attributes. - Add a ClickHouse-specific parse/deparse regression test for
SELECT tuple(1, 2, 3).2 FROM tuple_demo.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt | Updates function postfix grammar to recognize strict .[0-9]+ S_DOUBLE tokens as tuple positional access and store the index as a LongValue attribute. |
| src/test/java/net/sf/jsqlparser/statement/select/ClickHouseTest.java | Adds a regression test for ClickHouse tuple positional access .N parse/deparse behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+9631
to
+9632
| LOOKAHEAD({ getToken(1).kind == S_DOUBLE | ||
| && getToken(1).image.matches("\\.[0-9]+") }) |
Contributor
|
Thank you! |
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 #2442
Problem
ClickHouse supports tuple positional access using
tuple(...).N.JSQLParser tokenizes
.2asS_DOUBLE, so the existing function postfix grammar does not see a standalone.token and parsing fails.Fix
Keep the global numeric lexer unchanged. Recognize only strict
.[0-9]+S_DOUBLEtokens locally in theInternalFunctionpostfix and represent the position with the existingFunctionattribute andLongValueAST support.The existing
.+Function()/Column()postfix paths remain unchanged.Tests
Added a parse/deparse regression test for:
The full Gradle test suite and check pass, and JavaCC generation introduces no new warnings.