Skip to content

Fix inconsistent AST formatting for array/tuple with tuple element access - #96894

Merged
alexey-milovidov merged 1 commit into
masterfrom
fix-ast-formatting-array-tuple-parens
Feb 14, 2026
Merged

alexey-milovidov merged 1 commit into
masterfrom
fix-ast-formatting-array-tuple-parens

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Feb 14, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Fix BuzzHouse exception "Inconsistent AST formatting between Function_array and Literal_Array" in debug builds
  • PR Wrap complex tuple expressions with indexes in parentheses #96799 added size() > 1 parenthesization in tupleElement formatting to fix (tab.*).N, but it also wrapped array and tuple functions in unnecessary extra parens (e.g., ([['你们']]).3)
  • When re-parsed, the parser's fast literal path converts [['你们']] to ASTLiteral (size=1, no parens), producing [['你们']].3 — the formatted strings differ, triggering the debug AST consistency check
  • Exclude array and tuple functions from extra parenthesization since [...] and (...) syntax is already unambiguous with .N access
  • Revert unnecessary test reference changes from Wrap complex tuple expressions with indexes in parentheses #96799 where tuple(...) got wrapped in extra parens

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

Changelog category (leave one):

  • CI Fix or improvement

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Fix inconsistent AST formatting for array/tuple functions with .N tuple element access that caused exceptions in debug builds.

Test plan

  • Verified clickhouse-format produces consistent output for [['hello']].1, tuple(1,2,3).1, (tab.*).2, ((t1.1).1).1
  • All affected tests pass: 01852_cast_operator_4, 02560_tuple_format, 03780_AST_formatting_inconsistencies_in_debug_check, 03786_AST_formatting_inconsistencies_in_debug_check
  • Added regression test for array with .N access in 03786

🤖 Generated with Claude Code

Version info

  • Merged into: 26.2.1.679

…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]>
@clickhouse-gh

clickhouse-gh Bot commented Feb 14, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [20e3ac9]

Summary: ❌

job_name test_name status info comment
BuzzHouse (amd_debug) failure
Logical error: ColumnNullable is not compatible with original (STID: 4938-5ea2) FAIL cidb

@alexey-milovidov alexey-milovidov self-assigned this Feb 14, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member Author

Ok, I like it.

@alexey-milovidov
alexey-milovidov merged commit 66446ec into master Feb 14, 2026
130 of 131 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix-ast-formatting-array-tuple-parens branch February 14, 2026 23:40
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Feb 14, 2026
@george-larionov george-larionov added the post-approved Approved, but after the PR is merged. label Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

post-approved Approved, but after the PR is merged. 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.

3 participants