hililiwei commented on code in PR #7398:
URL: https://github.com/apache/iceberg/pull/7398#discussion_r1179855257


##########
core/src/main/java/org/apache/iceberg/TableMetadata.java:
##########
@@ -738,11 +738,16 @@ private static PartitionSpec freshSpec(int specId, Schema 
schema, PartitionSpec
     for (PartitionField field : partitionSpec.fields()) {
       // look up the name of the source field in the old schema to get the new 
schema's id
       String sourceName = 
partitionSpec.schema().findColumnName(field.sourceId());
-      specBuilder.addField(
-          field.transform().toString(),
-          schema.findField(sourceName).fieldId(),
-          field.fieldId(),
-          field.name());
+
+      final int fieldId;
+      if (sourceName != null) {
+        fieldId = schema.findField(sourceName).fieldId();
+      } else {
+        // In the case of a null sourceName, the column has been deleted.
+        // This only happens in V1 tables where the reference is still around 
as a void transform
+        fieldId = field.sourceId();
+      }
+      specBuilder.addField(field.transform().toString(), fieldId, 
field.fieldId(), field.name());

Review Comment:
   nit: new empty line? 



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