Repository navigation
Do not raise a logical error when a Merge table matches a table with no columns - #115896
Conversation
…no columns
ReadFromMerge::createChildrenPlans classifies a matched table whose metadata
snapshot has no columns. It recognised a parameterized view and an Alias with a
missing target, and treated everything else as an internal invariant violation.
An Alias whose target is a live parameterized view falls through both checks. A
parameterized view registers no columns by design (StorageView.cpp), and
StorageAlias forwards its target's metadata, so the alias presents that empty
column list. But StorageAlias does not override isView(), so it inherits the
IStorage default of false and the parameterized-view check short-circuits; the
target exists, so the missing-target check is false too. The remaining branch
raised LOGICAL_ERROR, which aborts the server in debug and sanitizer builds.
Two CI runs reached it on 2026-08-21 through merge('^'), one on master and one
on a pull request, with identical stacks.
Two changes at that site. The parameterized-view diagnosis now looks one hop
through an Alias, so such a table reports STORAGE_REQUIRES_PARAMETER, the same
error the view itself reports. The remaining case reports UNSUPPORTED_METHOD
naming the table and the Merge table, which is what fixes the class rather than
this one carrier: any matched table that cannot supply columns now produces a
proper error instead of an assertion, longer Alias chains included. This mirrors
the change made at the planner's getSmallestColumn site in ClickHouse#115716.
The empty column list is not itself a bad state, so there is nothing to correct
upstream of this point; the defect was that plan construction treated a
user-reachable condition as an internal one. Both existing messages are left
byte-identical. Making StorageAlias forward isView() was rejected as far too
broad for this, since that predicate also gates DDL validation, system.tables,
replication and materialized-view logic, and the header records a deliberate
split between predicates that resolve the target and predicates that fail
closed.
No setting, serialization format or new feature is involved, and the block
always threw, so no query that previously succeeded changes behaviour.
The regression test covers the observed carrier through both a Merge table and
the merge() table function, with FINAL and SAMPLE, a two-hop Alias chain, the
two already-classified carriers, and two positive arms that must still return
rows. It aborts an unpatched server, so it cannot pass vacuously.
Related: ClickHouse#104740
Related: ClickHouse#104790
Internal second-model review (1 blocker raised, disagreed with evidence)An independent model reviewed this diff cold against the pre-change revision. ❌ Blocker raised: "the new empty-column diagnosis bypasses the target table's
|
|
Workflow [PR], commit [808baad] Summary: ✅
AI ReviewSummaryThis PR changes Missing context / blind spots
Final Verdict✅ No review findings in the current diff. LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 14/19 (73.68%) · Uncovered code |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Compile time of recompiled translation units7 translation units recompiled, 20 s compile time in total, 7 of them have a recent master baseline. |
CI finish ledger: 3a3aa02Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
Not caused by this PR: the failing test file is not in this PR's diff, the cited frame is |
|
26.3 and 26.7 do not contain this fix, but the backports of #115716 (#119654, #119657) brought its test
Could A local 3-way merge is clean on 26.7. On 26.3 it conflicts, because 26.3 has an older version of this block and no |
Related: #104740
Related: #104790
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Reading through a
Mergetable that matches anAliastable whose target is a parameterized view no longer raisesLOGICAL_ERROR: Table has no columns.(which aborts the server in debug and sanitizer builds). Such a table now reportsSTORAGE_REQUIRES_PARAMETER, the same error the parameterized view itself reports. Any other matched table that cannot supply columns now reportsUNSUPPORTED_METHODinstead of an internal error.Description
ReadFromMerge::createChildrenPlansclassifies a matched table whose metadata snapshot has no columns. It recognised a parameterized view and anAliaswith a missing target, treating everything else as an internal invariant violation.An
Aliaswhose target is a live parameterized view falls through both. A parameterized view registers no columns by design (StorageView.cpp), andStorageAliasforwards its target's metadata, so the alias presents that empty list. ButStorageAliasdoes not overrideisView(), so the first check misses it, and its target exists, so the second misses it too. The result wasLOGICAL_ERROR, aborting the server in debug and sanitizer builds. Two CI runs hit it on 2026-08-21 throughmerge('^'), one of them on master.Two changes at that one site:
Alias, so the alias reports the sameSTORAGE_REQUIRES_PARAMETERas the view it points at;UNSUPPORTED_METHODnaming the table and theMergetable. That fixes the class, longerAliaschains included: any matched table that cannot supply columns gets a proper error rather than an assertion. It mirrors Report a clean error when a table expression has no columns to read #115716 at the planner'sgetSmallestColumnsite.The empty column list is not itself a bad state, so there is nothing to fix upstream; the defect was that plan construction treated a user-reachable condition as an internal one. Both existing messages are unchanged. Forwarding
isView()fromStorageAliaswas rejected as far too broad, since that predicate also gates DDL validation,system.tables, replication and materialized-view logic.No setting or serialization format is involved, and the path always threw, so no previously succeeding query changes.
The extended
04238_storage_alias_missing_target_mergeaborts an unpatched server, so it cannot pass vacuously. 50 randomized runs pass, and every failure in an 82-test sweep of this area reproduces identically unpatched.Workflow [PR]
Sync PR [sync-upstream/pr/115896]