rdblue commented on a change in pull request #499: Add persistent IDs to 
partition fields (WIP)
URL: https://github.com/apache/incubator-iceberg/pull/499#discussion_r361013901
 
 

 ##########
 File path: core/src/main/java/org/apache/iceberg/TableMetadata.java
 ##########
 @@ -63,21 +64,13 @@ public static TableMetadata 
newTableMetadata(TableOperations ops,
     Schema freshSchema = TypeUtil.assignFreshIds(schema, 
lastColumnId::incrementAndGet);
 
     // rebuild the partition spec using the new column ids
-    PartitionSpec.Builder specBuilder = PartitionSpec.builderFor(freshSchema)
-        .withSpecId(INITIAL_SPEC_ID);
-    for (PartitionField field : spec.fields()) {
-      // look up the name of the source field in the old schema to get the new 
schema's id
-      String sourceName = schema.findColumnName(field.sourceId());
-      specBuilder.add(
-          freshSchema.findField(sourceName).fieldId(),
-          field.name(),
-          field.transform().toString());
-    }
-    PartitionSpec freshSpec = specBuilder.build();
+    AtomicInteger lastPartitionFieldId = new 
AtomicInteger(PartitionSpec.PARTITION_DATA_ID_START - 1);
+    PartitionSpec freshSpec = freshSpecWithAssignIds(INITIAL_SPEC_ID, 
freshSchema, schema, spec, lastPartitionFieldId,
+        null);
 
 Review comment:
   I think that this should assign fresh IDs to the partition spec fields, but 
you can just add the ID to the existing code.
   
   Also, if you are using an `AtomicInteger`, you can use `getAndIncrement` to 
avoid needing to subtract 1 from the ID starting point.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to