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



##########
File path: core/src/main/java/org/apache/iceberg/TableMetadata.java
##########
@@ -718,18 +770,26 @@ public TableMetadata buildReplacement(Schema 
updatedSchema, PartitionSpec update
     newProperties.putAll(this.properties);
     newProperties.putAll(updatedProperties);
 
+    // determine the next schema id
+    int freshSchemaId = reuseOrCreateNewSchemaId(freshSchema);
+    ImmutableList.Builder<Schema> schemasBuilder = 
ImmutableList.<Schema>builder().addAll(schemas);
+
+    if (!schemasById.containsKey(freshSchemaId)) {
+      schemasBuilder.add(new Schema(freshSchemaId, freshSchema.columns()));
+    }
+
     return new TableMetadata(null, formatVersion, uuid, newLocation,
-        lastSequenceNumber, System.currentTimeMillis(), newLastColumnId.get(), 
freshSchema,
+        lastSequenceNumber, System.currentTimeMillis(), newLastColumnId.get(), 
freshSchemaId, schemasBuilder.build(),
         specId, specListBuilder.build(), Math.max(lastAssignedPartitionId, 
freshSpec.lastAssignedFieldId()),
         orderId, sortOrdersBuilder.build(), ImmutableMap.copyOf(newProperties),
         -1, snapshots, ImmutableList.of(), addPreviousFile(file, 
lastUpdatedMillis, newProperties));
   }
 
   public TableMetadata updateLocation(String newLocation) {
     return new TableMetadata(null, formatVersion, uuid, newLocation,
-        lastSequenceNumber, System.currentTimeMillis(), lastColumnId, schema, 
defaultSpecId, specs,
-        lastAssignedPartitionId, defaultSortOrderId, sortOrders, properties, 
currentSnapshotId,
-        snapshots, snapshotLog, addPreviousFile(file, lastUpdatedMillis));
+        lastSequenceNumber, System.currentTimeMillis(), lastColumnId, 
currentSchemaId, schemas, defaultSpecId, specs,
+        lastAssignedPartitionId, defaultSortOrderId, sortOrders, properties, 
currentSnapshotId, snapshots, snapshotLog,
+        addPreviousFile(file, lastUpdatedMillis));

Review comment:
       Looks like it isn't necessary to move `snapshots` and `snapshotLog`.




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

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