shihchengwei-lab commented on PR #19288:
URL: https://github.com/apache/iceberg/pull/19288#issuecomment-7368221870
The explicit identifier can silently move to a different field when several
renames are staged in the same `UpdateSchema`, so a successful commit can
persist the wrong equality key.
At `0d19af9c`, I reproduced this through the public `Table.updateSchema()`
path on format versions 1, 2, and 3. For a required struct `s` with required
integer children `id` and `group_id`, the identifier should stay on the
original `s.id` field, whose final name is `r.old_id`:
```java
int originalId = table.schema().findField("s.id").fieldId();
table.updateSchema()
.setIdentifierFields("s.id")
.renameColumn("s", "r")
.renameColumn("s.id", "old_id")
.renameColumn("s.group_id", "id")
.commit();
table.refresh();
assertThat(table.schema().identifierFieldIds()).containsExactly(originalId);
```
In all three runs, `originalId` was 4 but the reloaded schema contained
identifier ID 5, the original `s.group_id` field. The same sequence on base
`23a383e8` fails before commit with `Cannot add field old_id as an identifier
field`, so the silent wrong-ID commit is introduced by this change.
After the parent rename, `updateIdentifierFieldNames` stores `r.id`. The
later renames are still resolved against the original paths `s.id` and
`s.group_id`, so neither updates that saved path; `applyChanges` then resolves
`r.id` to the sibling that took the name. Flink also uses schema identifier IDs
as its default equality fields, so subsequent upserts or equality deletes can
use the wrong key.
Could the selected existing field be tracked by field ID throughout staged
renames (while retaining name resolution for newly added fields), and could
this combined sequence be covered by a regression test?
AI assistance: AI helped analyze the code, design the reproduction, and edit
this comment.
--
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]