Repository navigation
Conversation
A Nested member added by `ALTER TABLE ... ADD COLUMN` is absent from parts written before the ALTER. `fillMissingColumns` built a requested subcolumn of such a member by stripping the storage type to its scalar element, re-adding the subcolumn's own array levels and resolving the remaining subcolumn name against a default of that element. Subcolumn names are counted from the root of the column (`sizeN` counts arrays from the root, a JSON path below an array is resolved at that array level), so the remainder was resolved at the wrong level: `n.c.size1` of `Array(Array(UInt64))` failed with `There is no subcolumn size1 in type UInt64`, and `n.j.x.size1` of `Array(JSON(x Array(UInt8)))` produced a column of the wrong type (garbage values or a segfault in release builds, a bad cast in debug builds). When the shared offsets are the outer arrays of the member in storage, take the subcolumn with `IDataType::getSubcolumn` on the storage type from one default element wrapped in one-element arrays of the same depth, then replicate that element's value and wrap it in the known offsets, so the subcolumn is resolved by the same rule as for stored data and costs no more than the subcolumn itself. Other cases keep the existing code. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 3 rounds, 6 findings; the last round found nothing) plus my own review (3 rounds, 4 findings).
Severity: ❌ blocker / Session id: cron:clickhouse-review-self-slot-58:20261003-131200 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-self-slot-57:20261003-124000 |
|
Workflow [PR], commit [8485427] Summary: ✅
AI ReviewSummaryFixes default reconstruction for subcolumns of a Final VerdictStatus: ✅ Approve |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 11 s compile time in total, 7 of them have a recent master baseline. |
CI finish ledger - 2b0d93fEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
None of these touches the missing-column fill this PR changes, and Session id: cron:our-pr-ci-monitor:20261003-183140 |
|
Fixing PR for 05237_with_expression_alias_scope_descendant (DBReplicated): #123774 |
|
@groeneai, merge master. |
…sted-member-subcolumns Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Merged master in 512a6b5 (no conflicts, the fix itself is unchanged). On current master the test still fails with |
|
@groeneai this also fixes a segfault on 26.6: a The current test arms cover a typed path and no CREATE TABLE t_nested_add_final (id UInt64, v UInt64, `p.x` Array(Int64))
ENGINE = ReplacingMergeTree(v) ORDER BY id;
SYSTEM STOP MERGES t_nested_add_final;
INSERT INTO t_nested_add_final VALUES (1, 1, [1, 2]), (2, 1, [3]);
ALTER TABLE t_nested_add_final ADD COLUMN `p.j` Array(JSON);
INSERT INTO t_nested_add_final VALUES (1, 2, [7, 8, 9], ['{"r":["a","b"]}', '{"r":["c",1]}', '{"r":5}']), (2, 2, [10, 11], ['{"r":[1,2]}', '{"r":[2.5,"d",null]}']);
SELECT id, v, p.x, p.j.r.:`Array(Dynamic)`, p.j.r.:`Array(Nullable(String))` FROM t_nested_add_final FINAL ORDER BY id;
DROP TABLE t_nested_add_final;On this branch it returns: |
Before the fix, the placeholder filled for a typed JSON path of an Array(JSON) member had one Array level more than its type, so the FINAL merge of a ReplacingMergeTree aborted in ColumnDynamic::chooseDynamicStructureForMerge (SIGSEGV on 26.6.8.7 and 26.10.2.103). Case provided by the PR assignee. Also drop the Memory comment that predates ClickHouse#122991: Memory now finds the shared offsets in the stored block without a sibling read. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Added your case to
The same commit also removes a Memory comment that went stale after #122991. I added the |
The wrong structure of a missing `Nested` subcolumn is already fixed in master by #123690, which takes the subcolumn from the whole storage column. The dimension correction of this branch is not reached anymore, and it did not handle `sizeN` subcolumns, so remove it together with its test (covered by `05320_nested_member_added_by_alter_subcolumns`) and the structure check of filled columns. Keep the checked casts of source columns in `chooseDynamicStructureForMerge`, `takeOrCalculateStatisticsFrom`, `takeExactDynamicStructureFrom` and `prepareForSquashing`, so a source column of an unexpected structure becomes a `LOGICAL_ERROR` instead of corrupting memory. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Backport #123690 to 26.9: Fix reading a subcolumn of a `Nested` member added by `ALTER ADD COLUMN` from older parts
Backport #123690 to 26.10: Fix reading a subcolumn of a `Nested` member added by `ALTER ADD COLUMN` from older parts
…ted` member added by `ALTER ADD COLUMN` from older parts
…sted` member added by `ALTER ADD COLUMN` from older parts
Related: #116553
Related: #122991
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed reading a subcolumn of a
Nestedmember added byALTER TABLE ... ADD COLUMN(sizeN, or aJSONpath below the member's array) from parts written before theALTER. It failed withThere is no subcolumn, or produced a column of the wrong type, which returned garbage values or crashed the server, also in aFINALmerge.Description
On 26.8 (26.8.10.6),
SELECT n.c.size1of aNestedmember added byALTER TABLE ... ADD COLUMNfails withThere is no subcolumn size1on parts written before theALTER,n.j.x.size1of anArray(JSON(x Array(UInt8)))member returns garbage, andn.j.x.size0crashes the server (SIGSEGV; also on 26.3):A typed read of a
JSONpath of anArray(JSON)member withFINALon aReplacingMergeTreealso crashes (SIGSEGV inColumnDynamic::chooseDynamicStructureForMergeon 26.6.8.7 and 26.10.2.103): the column filled for the old part has an extraArraylevel.fillMissingColumnsbuilt such a subcolumn by stripping the member's type to its scalar element and resolving the rest of the subcolumn name against a default of that element. Subcolumn names count from the root of the column, so the name either did not exist (Map,Tuple,Variant,Dynamic,LowCardinality, deeper arrays) or named a different substream.When the shared offsets are the member's own outer arrays, the subcolumn is now taken by the storage type's
getSubcolumnfrom one default element wrapped in the member's arrays and replicated over the known offsets, so it is resolved like stored data and costs no more than the subcolumn. This also covers the shapes of #116553.Memoryreads without another member of the sameNestedwere fixed separately by #122991.The new test reads 16 subcolumns of 9 member shapes from Wide, Compact and Memory and checks every row of the pre-
ALTERpart against stored defaults, plus theFINALcase.Workflow [PR]
Sync PR [sync-upstream/pr/123690]
Version info
26.11.1.1381-master(included in26.11and later)