Repository navigation
Fix inconsistent AST formatting of an IN operand of a tuple element in a function argument - #124325
Conversation
…function argument `SELECT f((40 IN (1)).1[4], 38)` formatted as `f((((40 IN (1))).1)[4], 38)` and re-formatted as `f(((40 IN (1)).1)[4], 38)`, so the debug AST round-trip check aborted with "Inconsistent AST formatting" (BuzzHouse, STID 1941-1bfa). The `tupleElement` branch wraps a compound left operand in its own parens, but left `current_function` set. A direct IN child then added one more pair because it believed it was still a bare argument of `f`. After re-parsing, the outer pair becomes the `parenthesized` flag of the tuple element, whose emission clears `current_function`, so the IN pair disappears. Clear `current_function` for that wrapped operand, as the flag path in `decideParensEmission`, the IN's own wrap and the alias wrap already do. The only other visible change is that a redundant pair around such an IN is no longer printed, e.g. `f(((40 IN (1))).1, 38)` is now `f((40 IN (1)).1, 38)`; both forms parse to the same AST. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 0 findings) plus a separate cold review of the diff (0 blocker/major).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-11:20261006-220700 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-4:20261006-210400 |
|
Workflow [PR], commit [03e480a] Summary: ✅
AI ReviewSummaryThis PR fixes the stale Final Verdict
LLVM Coverage ReportMeasured on commit 03e480a.
Changed lines: Changed C/C++ lines covered: 3/3 (100.00%) · Uncovered code |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 9 s compile time in total, 7 of them have a recent master baseline. |
Related: #114883
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Formatting of a query where an
INis the left operand of a tuple element ((x IN (1)).1) inside a multi-argument function call is now stable across a format-parse-format round trip.Description
Requested in #114883 (comment). No related open issue found.
BuzzHouse (amd_debug)aborts withInconsistent AST formatting between 'ExpressionList' and 'ExpressionList'(STID 1941-1bfa) when anINis the left operand of a.Ntuple element inside a multi-argument call. Failing jobs: #114883, #117187. Minimal repro:SELECT f((40 IN (1)).1[4], 38)is formatted asf((((40 IN (1))).1)[4], 38)and re-formatted asf(((40 IN (1)).1)[4], 38).The
tupleElementbranch ofASTFunction::formatImplWithoutAliaswraps a compound left operand in its own parens but keepscurrent_functionset, so a directINchild adds one more pair as if it were a bare argument off. After re-parsing, the outer pair becomes the tuple element'sparenthesizedflag, whose emission clearscurrent_function, and theINpair disappears.The fix clears
current_functionfor that wrapped operand, as theparenthesizedflag path, theIN's own wrap and the alias wrap already do. The only other output change: a redundant pair around such anINis no longer printed (f(((40 IN (1))).1, 38)becomesf((40 IN (1)).1, 38)). Both forms parse to the same AST, on old and new versions.Not a
Bug Fix: the check is debug-only, and a tuple element over anINresult is never type-valid, so a release build (measured on 26.10.1.448) rejects these queries withILLEGAL_TYPE_OF_ARGUMENTbefore and after.Validation: the new test aborts a base server and passes 50/50 randomized runs with the fix; the formatter and parser stateless tests and parser gtests pass.
Workflow [PR]
Sync PR [sync-upstream/pr/124325]
Version info
26.10.1.1787-master(included in26.10and later)