Skip to content

Fix CTE column aliases for INTERSECT/EXCEPT queries - #110885

Merged
yariks5s merged 1 commit into
masterfrom
yarik/fix-cte-aliases-intersect-except
Aug 11, 2026
Merged

yariks5s merged 1 commit into
masterfrom
yarik/fix-cte-aliases-intersect-except

Conversation

@yariks5s

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 case when using CTE column aliases with INTERSECT or EXCEPT queries, e.g. WITH t (a, b) AS (SELECT 1, 2 INTERSECT SELECT 1, 2) SELECT a, b FROM t, the query was failing with UNKNOWN_IDENTIFIER error. Closes #104770

@clickhouse-gh

clickhouse-gh Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [0b2693f]

Summary: ✅


AI Review

Summary

This PR fixes the alias-propagation gap identified in #104770: buildSelectIntersectExceptQuery now preserves CTE column aliases the same way the UNION path already does, and the added stateless test covers the previously failing INTERSECT/EXCEPT cases. I did not find a remaining correctness, metadata, or test-coverage issue in the current patch.

Final Verdict
  • Status: ✅ Approve

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

clickhouse-gh Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.10% 86.00% -0.10%
Functions 91.80% 91.80% +0.00%
Branches 78.20% 78.20% +0.00%

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

Full report · Diff report

@yariks5s
yariks5s added this pull request to the merge queue Aug 11, 2026
Merged via the queue into master with commit b5ef948 Aug 11, 2026
349 of 351 checks passed
@yariks5s
yariks5s deleted the yarik/fix-cte-aliases-intersect-except branch August 11, 2026 12:47
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 11, 2026
@clickgapai

Copy link
Copy Markdown
Contributor

@yariks5s @Michicosun — ClickGap found the following in this PR:

Close anything that's wrong or already addressed.

groeneai added a commit to groeneai/ClickHouse that referenced this pull request Aug 12, 2026
ClickHouse#110885 landed the same buildSelectOrUnionExpression nested-union alias
forwarding this branch carried, so the conflicting hunk is resolved to
master's side and QueryTreeBuilder.cpp is left byte-identical to it. The
remaining fix is the two toAST emission sites, which master does not have:
the issue still reproduces on master at a96787f.

Also drop the ignore_drop_queries_probability = 0 pins from the test, as
requested on ClickHouse#112005.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

buildSelectIntersectExceptQuery missing aliases parameter causes CTE column aliases to fail for INTERSECT/EXCEPT queries

4 participants