Repository navigation
Conversation
A column that the data part does not store (added by `ALTER TABLE ... ADD COLUMN` after the part was written) is patched in the `AfterEvaluatingDefaults` stage, after the column has got its default. Two v1 patch parts that update different columns but both update such a column, e.g. `(s, a)` and `(n, a)`, both have `updated_columns = [a]` in that stage, so `applyPatchesToBlockLegacy` puts them into one group. Since ClickHouse#116007 the group header was built by `getUpdatedHeader(patches)` from all columns of the first patch block, `(a, n)`, instead of from the group's `[a]`. When the combined path is used (one of the patches updates a `String` column), `CombinedPatchBuilder::createPatchForColumn` then looks for `n` in every block of the group and the `(s, a)` block throws `NOT_FOUND_COLUMN_IN_BLOCK`. Reads, merges and `APPLY PATCHES` of such tables failed, including tables written by 26.7 and opened by 26.8+. Restore the behaviour from before ClickHouse#116007: `getUpdatedHeader` keeps only the columns the group was formed by, and the legacy groups are keyed by the column names instead of their hash. Closes ClickHouse#126612 Co-Authored-By: Claude Opus 5.5 <[email protected]>
The read after OPTIMIZE FINAL applied patch parts on the fly, so it passed even if the merge did not write the patched values. Read it with apply_patch_parts = 0, as the APPLY PATCHES half of the test already does. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review (click to expand)
|
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-7:20261019-111300 |
|
cc @Michicosun @scanhex12, could you review this and add the |
|
Workflow [PR], commit [bea12d4] Summary: ✅
AI ReviewSummaryThe PR fixes Missing context / blind spots
Final VerdictStatus: ✅ Approve. No code changes requested. |
…column The readers created for patch parts also skipped a subcolumn whose `Nullable` parent is converted with a `DEFAULT`, but nothing extracts it from the parent there, so the patch was not applied to the subcolumn. When the patched part lacks the column (added by `ALTER ADD COLUMN` after the part was written), the subcolumn of an updated row then read the `DEFAULT` instead of the updated value (`s.size` 3 for 'updated'). A patch part now provides such a subcolumn as stored. When the patched part extracts the subcolumn from its own column, the patch reads only that column, so its unconverted subcolumn does not overwrite the value extracted after the patch is applied to the column. With legacy (`v1`) patches, deferring the subcolumn to the last read stage makes the Merge and Join modes re-apply the column there, after its conversion, so a `NULL` the patch set throws `CANNOT_INSERT_NULL_IN_ORDINARY_COLUMN` (master returns the type default). ClickHouse#126698 fixes that re-application by restricting each stage to its own columns; the new test pins `patch_parts_version = 'v2'`. Reported in ClickHouse#125037 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed
NOT_FOUND_COLUMN_IN_BLOCKinSELECT, merges andALTER TABLE ... APPLY PATCHESon a table with two lightweightUPDATEs in the v1 patch part format (the only format before 26.8, orpatch_parts_version = 'v1') that both set a column added byALTER TABLE ... ADD COLUMN. Such tables written by 26.7 could not be read after an upgrade to 26.8. Closes #126612.Description
On 26.8.28.14 (LTS) and 26.9.19.9, reading, merging or running
APPLY PATCHESon a table with two v1 patch parts that both update a column added byADD COLUMNfails withNOT_FOUND_COLUMN_IN_BLOCK. 26.7.22.4 returns the right rows, and a data directory written by 26.7 becomes unreadable after the upgrade. Closes #126612, a regression from #116007.Root cause: a column the part does not store is patched after its default is evaluated (
AfterEvaluatingDefaults). In that stage the patches(s, a)and(n, a)both update only[a], soapplyPatchesToBlockLegacyputs them into one group, but since #116007 the group header was built from all columns of the first patch block,(a, n). The combined path (taken here because of theStringcolumn) then looks upnin every block of the group, and the(s, a)block throws.Change:
getUpdatedHeaderkeeps only the columns the group was formed by, and the legacy groups are keyed by the column names again, both as before #116007. The v2 (MergeOnKey) path is unchanged: its patch blocks already hold only the updated columns.Validation: the new test fails on master (
Not found column n in block, 20/20) and passes with the fix (50/50 with randomized settings). The lightweight update and patch part stateless tests show no new failures compared to master, also withpatch_parts_version = 'v1'as the server default.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/126698]