RussellSpitzer commented on code in PR #18252:
URL: https://github.com/apache/iceberg/pull/18252#discussion_r4540917573


##########
api/src/main/java/org/apache/iceberg/types/AssignFreshIds.java:
##########
@@ -48,15 +48,18 @@ class AssignFreshIds extends 
TypeUtil.CustomOrderSchemaVisitor<Type> {
     this.nextId = nextId;
   }
 
-  private int idFor(String fullName) {
+  private int idFor(int currentId, Type type) {
+    String fullName = name(currentId);
     if (baseSchema != null && fullName != null) {
-      Types.NestedField field = baseSchema.findField(fullName);
-      if (field != null) {
-        return field.fieldId();
+      Types.NestedField baseField = baseSchema.findField(fullName);
+      // a file derives its nested field IDs from its own ID, so reusing a 
base ID is only safe when
+      // the base field was already a file and had reserved that block
+      if (baseField != null && (!type.isFileType() || 
baseField.type().isFileType())) {
+        return baseField.fieldId();
       }
     }
 
-    return nextId.get();
+    return nextId.get(TypeUtil.numReservedIds(type));

Review Comment:
   Thats a good point, we really don't need the flexibility here. Changed



-- 
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