Repository navigation
Conversation
|
Workflow [PR], commit [3becabb] Summary: ❌
|
| { | ||
| dependencies.insert(column_name); | ||
| } | ||
| else if (identifier->compound() && candidate_names.contains(identifier->name_parts.front())) |
There was a problem hiding this comment.
identifier->compound() only catches the unquoted spelling b.x. ClickHouse also accepts full dotted paths as a single identifier token (existing tests already use forms like `c0.c2.null` and `m_ipv4.key_192.168.1.1`), and those are resolved elsewhere by splitting identifier->name() with Nested::getAllColumnAndSubcolumnPairs.
For a cyclic default written as `b.x` -> `c.x` -> `a.x`, column_name here is "b.x", candidate_names still only contains "b", and this branch is skipped because the identifier is no longer compound(). CREATE TABLE will still accept the cycle and the failure moves back to INSERT time. This needs to map subcolumn dependencies from the full identifier string (for example via Nested::tryGetColumnNameInStorage(column_name, candidate_names)) instead of only name_parts.front().
| a Tuple(x Int32, y Int32) DEFAULT (b.x, b.x), | ||
| b Tuple(x Int32, y Int32) DEFAULT (c.x, 2), | ||
| c Tuple(x Int32, y Int32) DEFAULT (a.x, 2) | ||
| ) ENGINE = Memory; -- {serverError CYCLIC_ALIASES} |
There was a problem hiding this comment.
This regression test only exercises the default enable_analyzer = 1 branch. The new pre-check runs from validateDefaultsWithAnalyzer, but validateColumnsDefaultsAndGetSampleBlockImpl still goes straight to the legacy TreeRewriter / ExpressionAnalyzer path when enable_analyzer = 0, so the same tuple-subcolumn cycle still slips through in the old-analyzer compatibility mode and fails later at INSERT time with UNKNOWN_IDENTIFIER.
Please either run the same cycle detection before both branches or add an explicit SET enable_analyzer = 0 case here. As written, the PR looks fixed in the default profile while remaining broken for a still-supported setting.
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 6/6 (100.00%) · Uncovered code |
A subcolumn written as one quoted token (`` `b.x` ``) is a non-compound `ASTIdentifier`, so `collectAliasDependenciesFromAST` missed its dependency on column `b` and `CREATE TABLE` accepted the cycle again. Map every identifier to its storage column with `Nested::tryGetColumnNameInStorage`, which covers both spellings and still prefers a column literally named `b.x`. ClickHouse#110435 (comment)
Closes: #107987
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
A cyclic
DEFAULTcolumn chain that passes through a tuple subcolumn reference (e.g.a DEFAULT b.x, b DEFAULT c.x, c DEFAULT a.x) is now correctly detected and rejected withCYCLIC_ALIASESatCREATE TABLEtime, instead of silently passing DDL validation and failing later atINSERTtime with a confusingUNKNOWN_IDENTIFIERerror.Workflow [PR]
Sync PR [sync-upstream/pr/110435]