Repository navigation
Conversation
The analyzer names a matched column whose bare name also binds to another table expression, an alias or an ARRAY JOIN expression with a qualified projection name (`r.a`), and an unprefixed `APPLY f` wraps that name (`toString(r.a)`). ClickHouse#109223 made the analyzer honor the `APPLY` name prefix, but seeded the prefixed name from the short column name, so `l.a` and `r.a` of a join both became `f_a`. Two different columns under one name then collide wherever the name is the key: `SELECT * FROM (...)` over the query reads the first `f_a` twice (wrong result, issue ClickHouse#122327 and the AST fuzzer "Subquery wrap oracle mismatch" on ClickHouse#121339 and in two other PRs), two different constants under one name fail the block structure check with `Code: 352 AMBIGUOUS_COLUMN_NAME`, and `remote()` over such a query fails with `Code: 44`. Seed the prefixed name from the column's projection name instead: `f_r.a`, the same base `*` and `APPLY f` use, and the same base a chained prefix after an unprefixed transformer already had (`q_toString(r.a)`). Names change only where the unprefixed name is already qualified: joins, a SELECT alias equal to a column name, an ARRAY JOIN clash and `tuple.*` (`f_tup.x`); a plain single-table `*` keeps `f_a`. A `REPLACE` result keeps the replaced column's name, so a `REPLACE (untuple(a) AS a)` expansion resets the accumulator to it (`a.1`, not `r.a.1`). The new test covers JOIN USING/ON, two tables, three joins, qualified and tuple matchers, join_use_nulls, a lambda, chained prefixes, named untuple and COLUMNS, with single-table and REPLACE controls. 04401 now expects `f_x.a` for a column qualified by a clashing SELECT alias, like its unprefixed `toString(x.a)`. Closes ClickHouse#122327 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Condense the seed comment of the APPLY prefix accumulator to one line. 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 on the code and tests), plus my own review of the same tree in two rounds.
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-9:20260928-152400 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-6:20260928-130800 |
|
Workflow [PR], commit [3c957a8] Summary: ✅
AI ReviewSummaryThis PR fixes named Final Verdict✅ No blocking issues found. LLVM Coverage ReportMeasured on commit 3c957a8.
Changed lines: Changed C/C++ lines covered: 13/13 (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, 20 s compile time in total, 7 of them have a recent master baseline. |
Closes: #122327
Related: #121339
Related: #109223
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Description
SELECT * APPLY (f, 'prefix')over a join gave two different columns one name, so a query that reads the result by name returned the wrong column:Other shapes failed instead: with
Code: 352 AMBIGUOUS_COLUMN_NAMEwhen the two results are different constants (toTypeName, for example), and withCode: 44 ILLEGAL_COLUMNforremote()over a prefixed join.The analyzer names a column that another table expression of the scope could also bind with a qualifier (
r.a), andAPPLY fwraps that name (toString(r.a)). #109223 made the analyzer honor the prefix, but built the name from the short column name, sol.aandr.aboth becamef_a. The prefix now goes on the same name that*andAPPLY fuse (f_r.a), and aREPLACEresult keeps the replaced column's name. Names change only where the unprefixed name is qualified (joins, aSELECTalias equal to a column name,ARRAY JOIN,tuple.*), which is why04401now expectsf_x.a.Found by
AST fuzzer (amd_release, oracle)on #121339 ("Subquery wrap oracle mismatch", report); the same shape also failed in the fuzzer runs of two other PRs.The new test fails before this change (wrong values and
Code: 352) and passes after it, also in 50 randomized runs; the stateless tests that useAPPLYpass. Not for changelog: #109223 is only on master, not in 26.9.Workflow [PR]
Sync PR [sync-upstream/pr/122702]
Version info
26.10.1.1086-master(included in26.10and later)