rdblue commented on a change in pull request #3421:
URL: https://github.com/apache/iceberg/pull/3421#discussion_r739884458



##########
File path: core/src/main/java/org/apache/iceberg/TableMetadata.java
##########
@@ -743,19 +743,23 @@ private PartitionSpec reassignPartitionIds(PartitionSpec 
partitionSpec, TypeUtil
 
     } else {
       // for v1, preserve the existing spec and carry forward all fields, 
replacing missing fields with void
-      Map<Pair<Integer, String>, PartitionField> newFields = 
Maps.newLinkedHashMap();
+      Map<Integer, PartitionField> newFields = Maps.newLinkedHashMap();
       for (PartitionField newField : partitionSpec.fields()) {
-        newFields.put(Pair.of(newField.sourceId(), 
newField.transform().toString()), newField);
+        newFields.put(newField.sourceId(), newField);
       }
 
       for (PartitionField field : spec().fields()) {
         // ensure each field is either carried forward or replaced with void
-        PartitionField newField = newFields.remove(Pair.of(field.sourceId(), 
field.transform().toString()));
+        PartitionField newField = newFields.remove(field.sourceId());
         if (newField != null) {
           // copy the new field with the existing field ID
           specBuilder.add(newField.sourceId(), field.fieldId(), 
newField.name(), newField.transform());
         } else {
-          specBuilder.add(field.sourceId(), field.fieldId(), field.name(), 
Transforms.alwaysNull());
+          // Cosmetic so that the field names match the logic in 
BaseUpdatePartitionSpec
+          String newFieldName = 
field.transform().equals(Transforms.alwaysNull()) ?

Review comment:
       Instead of always renaming with the field ID, I think this logic should 
be updated with a set of the new field names. If this field's name is in the 
set of new field names, then it must be replaced using the _fieldID suffix. 
Otherwise we should leave it as it is to avoid problems with metadata queries.




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