Skip to content

fix: support ClickHouse tuple positional access - #2454

Merged
manticore-projects merged 1 commit into
JSQLParser:masterfrom
jianjindream:fix/2442-clickhouse-tuple-positional-access
Aug 8, 2026
Merged

fix: support ClickHouse tuple positional access#2454
manticore-projects merged 1 commit into
JSQLParser:masterfrom
jianjindream:fix/2442-clickhouse-tuple-positional-access

Conversation

@jianjindream

Copy link
Copy Markdown
Contributor

Fixes #2442

Problem

ClickHouse supports tuple positional access using tuple(...).N.
JSQLParser tokenizes .2 as S_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_DOUBLE tokens locally in the InternalFunction postfix and represent the position with the existing Function attribute and LongValue AST support.

The existing . + Function() / Column() postfix paths remain unchanged.

Tests

Added a parse/deparse regression test for:

SELECT tuple(1, 2, 3).2 FROM tuple_demo

The full Gradle test suite and check pass, and JavaCC generation introduces no new warnings.

@jianjindream
jianjindream marked this pull request as ready for review August 8, 2026 07:35
Copilot AI lite review requested due to automatic review settings August 8, 2026 07:35

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

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 InternalFunction postfix parsing to accept strict S_DOUBLE tokens matching .[0-9]+ and map them to a LongValue function 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]+") })
@manticore-projects

Copy link
Copy Markdown
Contributor

Thank you!

@manticore-projects
manticore-projects merged commit 5bec712 into JSQLParser:master Aug 8, 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 5.4-SNAPSHOT : ClickHouse : Tuple positional access via .N not supported in SELECT

3 participants