Skip to content

Wrap complex tuple expressions with indexes in parentheses - #96799

Merged
alexey-milovidov merged 2 commits into
masterfrom
ast-inconsistency-with-tuple-indexing
Feb 14, 2026
Merged

alexey-milovidov merged 2 commits into
masterfrom
ast-inconsistency-with-tuple-indexing

Conversation

@george-larionov

@george-larionov george-larionov commented Feb 13, 2026 •

Copy link
Copy Markdown
Member

Fix issues with complex tuple expressions, such as:

SELECT (tab.*).2 FROM tab;

See this failure.

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

Version info

  • Merged into: 26.2.1.659

@george-larionov
george-larionov force-pushed the ast-inconsistency-with-tuple-indexing branch 2 times, most recently from 4a9617a to df44040 Compare February 13, 2026 02:22
@clickhouse-gh

clickhouse-gh Bot commented Feb 13, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [8bb79c5]

Summary: ✅

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Feb 13, 2026
@george-larionov
george-larionov marked this pull request as ready for review February 13, 2026 02:23
@antaljanosbenjamin antaljanosbenjamin self-assigned this Feb 13, 2026
@george-larionov
george-larionov force-pushed the ast-inconsistency-with-tuple-indexing branch from df44040 to 8bb79c5 Compare February 13, 2026 15:45
@george-larionov

Copy link
Copy Markdown
Member Author

Updated a few tests to match new changes:

In 01852_cast_operator_4:

-SELECT CAST(CAST(tuple(3, 4, 5), \'Tuple(UInt64, UInt64, UInt64)\').1, \'Int32\')
+SELECT CAST((CAST(tuple(3, 4, 5), \'Tuple(UInt64, UInt64, UInt64)\')).1, \'Int32\')

It is a bit more clunky now but I think a reasonable trade off, since it should be a rare case anyway.

And in 02560_tuple_format:

-SELECT tuple(1, 2, 3).1
+SELECT (tuple(1, 2, 3)).1

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ok, although ((t1.1).1).1 does not look pretty.

@alexey-milovidov

Copy link
Copy Markdown
Member

But it's good enough as an immediate fix for CI failures.

@alexey-milovidov
alexey-milovidov merged commit c9c0234 into master Feb 14, 2026
131 checks passed
@alexey-milovidov
alexey-milovidov deleted the ast-inconsistency-with-tuple-indexing branch February 14, 2026 00:55
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Feb 14, 2026
alexey-milovidov added a commit that referenced this pull request Feb 14, 2026
…nt access

PR #96799 added parenthesization around the left operand in `tupleElement`
formatting when `size() > 1`, to fix `(tab.*).N` formatting. However, this
check was too broad: it also wrapped `ASTFunction("array")` and
`ASTFunction("tuple")` in extra parens (e.g., `([['你们']]).3`).

When re-parsed, the parser's fast literal path converts `[['你们']]` to
`ASTLiteral(Array(...))` which has `size() == 1`, so no parens are added
on the second format pass. The formatted strings differ, triggering the
debug AST consistency check exception.

The fix excludes `array` and `tuple` functions from the extra
parenthesization since their bracket syntax (`[...]` and `(...)`) is
already unambiguous with `.N` access. The necessary parens for
`(tab.*).N` and `((t1.1).1).1` are preserved.

https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=96871&sha=8c08d137d9d40503cff353ed51ec4c8cf55e9d38&name_0=PR&name_1=BuzzHouse%20%28amd_debug%29

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-not-for-changelog This PR should not be mentioned in the changelog pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants