zhongyujiang commented on code in PR #4535:
URL: https://github.com/apache/iceberg/pull/4535#discussion_r847221517
##########
core/src/main/java/org/apache/iceberg/SchemaUpdate.java:
##########
@@ -438,13 +438,18 @@ private static Schema applyChanges(Schema schema,
List<Integer> deletes,
Multimap<Integer, Types.NestedField> adds,
Multimap<Integer, Move> moves,
Set<String> identifierFieldNames) {
- // validate existing identifier fields are not deleted
+ Map<Integer, Integer> idToParent =
TypeUtil.indexParents(schema.asStruct());
+
for (String name : identifierFieldNames) {
Types.NestedField field = schema.findField(name);
if (field != null) {
- Preconditions.checkArgument(!deletes.contains(field.fieldId()),
- "Cannot delete identifier field %s. To force deletion, " +
- "also call setIdentifierFields to update identifier fields.",
field);
+ Integer idNotToDelete = field.fieldId();
+ while (idNotToDelete != null) {
+ Preconditions.checkArgument(!deletes.contains(idNotToDelete),
+ "Cannot delete identifier field %s. To force deletion, " +
+ "also call setIdentifierFields to update identifier
fields.", field);
+ idNotToDelete = idToParent.get(idNotToDelete);
+ }
Review Comment:
Now deleting struct type columns with nested identifier fields will also
fail bacause this check, just the failure message can be a little confusing.
https://github.com/apache/iceberg/blob/910f2712c7b731181c4a72fb6b8c66addeb76dd9/core/src/main/java/org/apache/iceberg/SchemaUpdate.java#L456-L463
--
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]