ShivanshhhG opened a new pull request, #19288:
URL: https://github.com/apache/iceberg/pull/19288

   Fixes #19285.
   
   ### Problem
   Renaming a nested identifier field (e.g. `s.id` -> `id2`) or its parent 
struct (`s` -> `r`) in `SchemaUpdate` broke identifier fields:
   1. `renameColumn` replaced `s.id` in `identifierFieldNames` with the leaf 
`newName` (`id2`), causing `applyChanges` to either fail with `Cannot add field 
id2 as an identifier field: not found` or silently switch to a top-level column 
with the same leaf name.
   2. Renaming a parent struct (`s` -> `r`) left stale `s.id` paths in 
`identifierFieldNames`.
   
   ### Solution
   - Track `identifierFieldsExplicitlySet` in `SchemaUpdate`. When 
`setIdentifierFields` was not explicitly called, preserve 
`schema.identifierFieldIds()` in `applyChanges` (after still building 
`nameToId` to validate field name uniqueness/case-sensitivity) so renames/moves 
on nested or parent columns do not corrupt existing identifier field IDs.
   - Update `renameColumn` to rewrite matching or descendant paths in 
`identifierFieldNames` via `updateIdentifierFieldNames`, keeping the parent 
path prefix intact and updating descendant paths when a parent struct is 
renamed (including when `setIdentifierFields` was explicitly called).
   - Add `TestSchemaUpdate#testRenameNestedIdentifierFields` covering nested 
field renames (including leaf collision with top-level column), parent struct 
renames, case-insensitive renames, and explicit `setIdentifierFields` + rename.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to