Repository navigation
Cherry pick #128525 to 26.10: Fix Iceberg ADD COLUMN reusing a nested field id when last-column-id is too small - #128982
Merged
Conversation
…small ClickHouse 26.3 and 26.6 wrote `last-column-id` as the number of top-level columns, ignoring the ids of nested fields (list element, map key/value, struct children). `generateAddColumnMetadata` took the next id from that value, so the first `ALTER TABLE ... ADD COLUMN` on a newer version gave the new column an id that a nested field already had, and every later read failed with `Duplicate field id N (ICEBERG_SPECIFICATION_VIOLATION)`. Measured with official images: a table created by 26.6.8.7 or 26.3.42.3, then altered by 26.8.34.13. New ids now start after max(`last-column-id`, the largest field id of every schema in `schemas`, nested ids included). All schemas, not only the current one, because a dropped column keeps its ids in older schemas and in old data files. The walk reuses `IcebergSchemaProcessor::traverseSchema`, the same walk the reader uses to map field ids, and `traverseComplexType` gets a stack-size check because it now also runs over historical schemas that no read has parsed. #110884 fixed `last-column-id` for new tables; its first version also had this upgrade path for the current schema, which was dropped during review (#110884 (comment)). Issue #128455 is the measured upgrade case that needs it. Closes #128455. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`getLastAssignedFieldId` took the max over `traverseSchema`, which keys ids by dotted path, so a top-level column named `a.b` overwrote the id of field `b` of a tuple `a` and that id could be assigned again. A small recursive walk now collects only the ids, without building a path for every field of every schema. The stack-size check moves to it from `traverseComplexType`. The test now reads the lowered `last-column-id` through a second table over the same path, as a newer server opening an old table does, and covers a `Map` column and the dotted-name case. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`collectTimeFieldIds` already walked every field, list element and map key/value id of a schema. Turn it into a `forEachFieldId` visitor (with `checkStackSize`) and use it both for the `time` field ids and for `getMaxFieldId`, instead of a second recursive walker. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…mall-last-column-id Fix Iceberg `ADD COLUMN` reusing a nested field id when `last-column-id` is too small
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Original pull-request #128525
Do not merge this PR manually
This pull-request is a first step of an automated backporting.
It contains changes similar to calling
git cherry-picklocally.If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.
The check results does not matter at this step - you can safely ignore them.
Before you resolve anything
Conflicts are often caused by a prerequisite change that has not been backported yet, rather than by a real divergence. The bot re-tries this cherry-pick against the release branch on every run, so if that is the case here it will merge itself as soon as the prerequisite lands, and you will see a comment saying so. Manual resolution is only needed while the conflict persists.
Troubleshooting
If the conflicts were resolved in a wrong way
If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:
pr-cherrypicklabel from the PRYou also need to check the Original pull-request for
pr-backports-createdlabel, and delete if it's presented thereThe PR source
The PR is created in the CI job