Repository navigation
Keep carried-over Iceberg manifest-list counts in the new list's shape after a format-version upgrade - #130800
Conversation
After another engine upgrades an Iceberg table from format version 1, the first ClickHouse commit (INSERT, ALTER DELETE/UPDATE, DROP PARTITION) copies the parent's v1 manifest-list entries into a v2 or v3 list. The six counts are ["null", int/long] unions in v1 and plain values in v2/v3, and the copy assigned the source GenericDatum verbatim. avro-cpp's GenericWriter encodes a union index for any datum that is itself a union, whatever the writer schema says, so every count got an extra varint and the rest of the file was misaligned: every later read of the table failed with INCORRECT_DATA. The three file counts were also looked up only by their current names. Iceberg Java before 1.5 calls them added_data_files_count and so on (same field ids, Java resolves by id), so for such a parent list the new entries got 0 file counts, and Java scans skip a manifest whose added and existing file counts are 0. Each count is now rebuilt from its value with setVersionedField, which writes the target field's shape, and the file counts fall back to the old names. A missing or null count cannot be written into a v2/v3 list (the spec requires it there, and recomputing it from the manifest is not implemented), so that case now throws NOT_IMPLEMENTED before anything is committed instead of writing a corrupt or zero count; a v1 target keeps it null as before. Closes ClickHouse#123045 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Condense the copy_count comment from 3 lines to 2. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [906b374] Summary: ✅
AI ReviewSummaryReviewed #130800 at Missing context / blind spots
Final Verdict✅ Approve — no unresolved code findings or required revisions. |
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 1 finding) plus my own cold review (2 nits).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-10:20261111-130700 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-6:20261111-124501 |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Slowest function optimization changes (ThinLTO)Median per-function time ratio to the master baseline:
Compile time of recompiled translation units56 translation units recompiled, 577 s compile time in total, 56 of them have a recent master baseline. |
1937515
…t-list-bucket-partition-summary Conflict in IcebergWrites.cpp, two hunks: - The summary write loop: master (ClickHouse#129812) only reworded the comment on its `bounds_unavailable` check. Kept this branch's form, which has no check: `canWritePartitionSummary` already returns early for a manifest with such a field. - The manifest-list carry-forward: master (ClickHouse#130800) rebuilds each count in the new list's shape with `copy_count`. Took master's counts and kept this branch's guarded copy of `partitions`. Conflict in ChunkPartitioner.h: master added `[[nodiscard]]` to `getResultTypes`; kept it together with this branch's comment. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Closes: #123045
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed an Iceberg table becoming unreadable (
INCORRECT_DATA) when another engine had upgraded it from format version 1 to 2 or 3 and ClickHouse then made the next commit (INSERT,ALTER TABLE ... DELETE/UPDATE,ALTER TABLE ... DROP PARTITION). Also fixed any ClickHouse commit writing 0 as the file counts of manifests listed by Iceberg Java before 1.5, which made Java-based readers skip those manifests. Closes #123045.Description
On 26.10.2.103, after another engine upgrades an Iceberg table from format version 1 to 2, the first ClickHouse
INSERTmakes every later read of the table fail withCannot read Iceberg avro manifest file ...: Invalid value for bool. (INCORRECT_DATA).generateManifestListcopies the parent snapshot's manifest-list entries into the new list. In a v1 list the six*_files_count/*_rows_countfields are["null", int/long]unions, in v2/v3 they are plain, and the copy assigned the source datum verbatim. avro-cpp encodes a union index for any datum that is itself a union, so the rest of the file was misaligned. The same copy looked the file counts up only by their current names, while Iceberg Java before 1.5 names themadded_data_files_countetc. (same field ids), so any ClickHouse commit to a table whose current list Java wrote, upgraded or not, wrote them as 0, and Java scans skip a manifest with no added or existing files.Each count is now rebuilt with
setVersionedFieldin the target field's shape, with a fallback to the old names, and a count of the wrong Avro type fails withICEBERG_SPECIFICATION_VIOLATION. A missing or null count cannot go into a v2/v3 list, so that case now fails withNOT_IMPLEMENTEDbefore anything is committed; none of the 135 manifest lists undertests/has one, and no ClickHouse writer produces one, so it has no test. Lists that were already written correctly do not change.The new test (v1 -> v2 and v1 -> v3
INSERTs, and a copy of the Iceberg 1.4.3 fixtureice143_v2_position_deletes) fails on master and passes with the fix. Locally,ALTER TABLE ... DELETE,UPDATEandDROP PARTITIONafter the upgrade are red on master and green with the fix.Workflow [PR]
Sync PR [sync-upstream/pr/130800]
Version info
26.11.1.2024-master(included in26.11and later)