Skip to content

Reject duplicate names in CTE and table expression column alias lists - #114505

Merged
serxa merged 2 commits into
masterfrom
yarik/reject-duplicate-cte-column-aliases
Oct 9, 2026
Merged

serxa merged 2 commits into
masterfrom
yarik/reject-duplicate-cte-column-aliases

Conversation

@yariks5s

@yariks5s yariks5s commented Aug 12, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

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

Fixes a bug where the query gave incorrect result on duplicated column alias name in CTE and table expression (must be rejected). Closes #114427

Version info

  • Merged into: 26.10.1.1886-master (included in 26.10 and later)

@clickhouse-gh

clickhouse-gh Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [ad892cb]

Summary: ✅


AI Review

Summary

This PR moves duplicate-alias validation into the shared projection-alias override path used by CTE alias lists and table-expression column alias lists, and adds focused stateless coverage for the previously silent column-collapse cases. I did not find a remaining correctness, safety, or evidence gap in the current patch; the change matches the promised behavior and the PR CI is all green.

Final Verdict
  • Status: ✅ Approve

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.70% 86.70% +0.00%
Functions 92.00% 92.00% +0.00%
Branches 79.00% 79.10% +0.10%

Changed lines: Changed C/C++ lines covered: 17/17 (100.00%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Aug 12, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 35 queries analysed

This PR is a pure refactor: it extracts a shared helper for parsing CTE/table-expression column-alias lists (the name (col1, col2, ...) syntax) and adds duplicate-alias rejection, plus a test. None of the flagged ClickBench or TPC-H queries use column-alias lists, so the changed code is never executed on these benchmarks and cannot plausibly move any median in either direction. All five flagged improvements have therefore been downgraded to not_sure — the deltas (including the large TPC-H Q7/Q8 and ClickBench Q23 shifts) are baseline/co-location and run-to-run variance, not effects of this change. No genuine regressions or improvements attributable to the diff.

clickbench

⚠️ 3 inconclusive

Flagged queries (3 of 43)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
⚠️ 17 not_sure 556 484 -12.9% <0.0001 This PR only refactors CTE/table-expression column-alias-list handling in query-tree building; Q17 uses no such alias lists, so the -12.9% shift is unrelated run-to-run variance.
⚠️ 23 not_sure 167 79 ×2.1 faster <0.0001 Same off-path alias-list refactor; combined with this query's noisy history and wide source spread, the "×2.1 faster" reading is variance, not a PR effect.
⚠️ 32 not_sure 1320 1459 +10.5% 0.0025 Borderline +10.5% with mixed signals from the two tests, and off this refactor's code path — treat as noise, not a real change.

Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on.

tpch_adapted_1_official

⚠️ 2 inconclusive

Flagged queries (2 of 22)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
⚠️ 7 not_sure 574 71 ×8.1 faster <0.0001 The column-alias-list refactor doesn't touch Q7's execution path (no CTE alias lists), so the "×8.1 faster" delta is an environment/baseline artifact, not this change.
⚠️ 8 not_sure 175 81 ×2.2 faster <0.0001 Off-path for the same reason as Q7; Q8 exercises no CTE/table-expression alias lists, so the "×2.1 faster" reading is variance rather than a PR effect.

Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on.

Debug info
  • StressHouse run: 89ef053c-598b-48a1-94f2-2edbba855215
  • MIRAI run: a4411074-9724-4183-b1c9-0d195652c12e
  • PR check IDs:
    • clickbench_1094842_1786645810
    • clickbench_1094848_1786645810
    • clickbench_1094859_1786645810
    • tpch_adapted_1_official_1094871_1786645810
    • tpch_adapted_1_official_1094884_1786645810
    • tpch_adapted_1_official_1094919_1786645811

@clickhouse-gh clickhouse-gh Bot added the comp-query-analyzer Semantic analysis + logical/physical planning + rewrites (Analyzer and Planner modules). label Sep 4, 2026
@serxa serxa self-assigned this Oct 7, 2026
@serxa
serxa added this pull request to the merge queue Oct 8, 2026
Merged via the queue into master with commit e47f0cb Oct 9, 2026
181 checks passed
@serxa
serxa deleted the yarik/reject-duplicate-cte-column-aliases branch October 9, 2026 00:28
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 9, 2026
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Oct 9, 2026
…ckHouse#114505

The same duplicate-name check for `WITH t(a, a)` and `AS t(a, a)` column
alias lists landed on master in ClickHouse#114505 at both `QueryTreeBuilder` sites,
so this branch keeps master's version instead of its own helper.

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

Labels

comp-query-analyzer Semantic analysis + logical/physical planning + rewrites (Analyzer and Planner modules). pr-bugfix Pull request with bugfix, not backported by default 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.

CTE column alias list is not checked for duplicate names; columns silently collapse

3 participants