Repository navigation
Forbid Tuple element name null to prevent subcolumn ambiguity - #98377
Conversation
For `Nullable(Tuple(null UInt32))`, the subcolumn name `null` is ambiguous — it matches both the Nullable's null-map and the Tuple element named `null`. This causes an exception in `SerializationNullable::enumerateStreams` because the type and serialization resolve to different things via different code paths. Rather than patching the resolution logic, forbid the ambiguous name at type creation time in `checkTupleNames`. Closes #96681 CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=98293&sha=f68ee0d3f6944d6418c2304965c72af57a2e9971&name_0=PR&name_1=AST%20fuzzer%20%28arm_asan%29 Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
Workflow [PR], commit [f903d4f] Summary: ✅ AI ReviewSummaryThis PR forbids Findings❌ Blockers
Tests
ClickHouse Rules
Final Verdict
|
…nto Nested types When a query accesses `.null` subcolumns on `Array(Nullable(T))` columns (e.g. `SELECT a3.null FROM t`), the subcolumn `a3.null` has type `Array(UInt8)`. Both `StorageLog` and `IMergeTreeReader` call `Nested::convertToSubcolumns`, which internally calls `getSubcolumnsOfNested`. This function found `a3.null` (an Array with a dotted name), split it into prefix `a3` / suffix `null`, and tried to create `Array(Tuple(null UInt8))` — triggering the new check that forbids `null` as a Tuple element name. The fix: skip entries where `isSubcolumn()` is true, since these are derived subcolumns (like `.null`, `.size0`), not real flat-nested columns (like `n.a Array(T)`, `n.b Array(T)`). Co-Authored-By: Claude Opus 4.6 <[email protected]>
…lement-name # Conflicts: # src/DataTypes/NestedUtils.cpp
| if (name.empty()) | ||
| return Exception(ErrorCodes::BAD_ARGUMENTS, "Names of tuple elements cannot be empty"); | ||
|
|
||
| if (name == "null") |
There was a problem hiding this comment.
This check is applied in DataTypeTuple construction globally, so it is also hit when loading existing metadata/types (not only on new CREATE/ALTER).
That makes this a hard backward-incompatible parse failure for already-existing schemas that contain Tuple(null ...) and can prevent table attach/startup paths. Per ClickHouse compatibility policy, please gate this with a compatibility/setting path (or apply only to newly created objects) so old metadata can still be loaded.
| -- The column `t` is Nullable(Tuple(null UInt32)), so `t.null` could mean either | ||
| -- the null-map of the Nullable or the "null" element of the Tuple. | ||
| -- This should not cause an exception. | ||
| SELECT CAST((1), 'Tuple(null UInt32)'); -- { serverError BAD_ARGUMENTS } |
There was a problem hiding this comment.
This test covers new rejection paths, but the compatibility risk is loading existing metadata that already contains Tuple(null ...) during ATTACH/startup.
Please add a test that verifies legacy metadata loading behavior (or compatibility-gated behavior), so this backward-incompatible path is explicitly covered.
|
The Stress test (arm_msan) failure is fixed by #101239, which should be merged first. After it is merged, please update the branch to include the fix. |
Reword the message so it makes sense for both `Nullable(Tuple(...))` and plain `Tuple(...)` usages. The previous wording said the name conflicts with the null-map subcolumn, but the check applies to all Tuples, not only those inside `Nullable`. The new wording explains that `null` is reserved because it would clash if such a tuple is later wrapped in `Nullable`. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This covers the scenario fixed by the previous commit `Fix Nested::getSubcolumnsOfNested incorrectly grouping subcolumns into Nested types`. Without that fix, reading `a3.null` from a column of type `Array(Nullable(T))` triggered the new `checkTupleNames` exception via `Nested::convertToSubcolumns` because the derived subcolumn was incorrectly fed back into Nested grouping. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
LLVM Coverage Report
Changed lines: 75.00% (6/8) · Uncovered code |
alexey-milovidov
left a comment
There was a problem hiding this comment.
I think this is reasonable...
|
Hi @alexey-milovidov — while reviewing this PR I found the following:
Could you review the test PR and add the |
PR ClickHouse#98377 (`Forbid Tuple element name `null` to prevent subcolumn ambiguity`) makes the new server reject attaching any pre-existing table whose schema contains `Tuple(null ...)`. The stress test `01872_functions_to_subcolumns_analyzer.sql` historically created such a table (`t_tuple_null` with `Tuple(null UInt32)`); after upgrade, the new server logs a `BAD_ARGUMENTS` error from `AsyncLoader::worker` while attempting to attach it. This is the new validation working as intended, not a regression — the table is left detached, but the error surfaces in the upgrade check as `Error message in clickhouse-server.log (see upgrade_error_messages.txt)`. Add the message to the upgrade-check error allowlist so that this expected post-upgrade rejection does not fail the check. Example failing run (as reproduced on PR ClickHouse#100300): https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=100300&sha=a93523dfa84eebfb7bd5b2f25596f01e2e18ab2e&name_0=PR&name_1=Upgrade%20check%20%28amd_release%29
The upgrade test in CI installs a previous release binary, runs the test suite, then upgrades to the new server build and restarts. Tables created on the old binary with columns like `Nullable(Tuple(`null` UInt32))` fail to attach on the new binary because PR ClickHouse#98377 forbade Tuple element name `null` to avoid ambiguity with the Nullable null-map subcolumn name. This is a known consequence of the backward-incompatible change, not a regression introduced by any in-flight PR. Add the exact reserved-name phrase to the upgrade-runner error filter so unrelated PRs no longer fail the upgrade check on this message. Observed on PR ClickHouse#100141: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=100141&sha=ca91e01ef6f3c799bddb2176485608a8c9eaf151&name_0=PR&name_1=Upgrade%20check%20%28amd_release%29 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Summary
nullincheckTupleNames(DataTypeTuple.cpp) because it conflicts with the subcolumn name used for Nullable null maps, causing an exception inSerializationNullable::enumerateStreams04000_nullable_tuple_null_subcolumn_ambiguityvalidating the new restriction01872_functions_to_subcolumns_analyzerto renameTuple(null UInt32)→Tuple(n UInt32)Closes #96681
CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=98293&sha=f68ee0d3f6944d6418c2304965c72af57a2e9971&name_0=PR&name_1=AST%20fuzzer%20%28arm_asan%29
#98293
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Tuple element name
nullis now forbidden because it conflicts with the subcolumn name used for Nullable null maps, causing ambiguous subcolumn resolution.Documentation entry for user-facing changes
🤖 Generated with Claude Code
Version info
26.5.1.235