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_r361012368
########## File path: core/src/main/java/org/apache/iceberg/TableMetadata.java ########## @@ -312,15 +314,20 @@ public TableMetadata updatePartitionSpec(PartitionSpec newPartitionSpec) { Preconditions.checkArgument(defaultSpecId != newDefaultSpecId, "Cannot set default partition spec to the current default"); + // start from last partition spec's fieldId + AtomicInteger nextPartitionFieldId = new AtomicInteger(lastPartitionFieldId); ImmutableList.Builder<PartitionSpec> builder = ImmutableList.<PartitionSpec>builder() .addAll(specs); if (!specsById.containsKey(newDefaultSpecId)) { // get a fresh spec to ensure the spec ID is set to the new default - builder.add(freshSpec(newDefaultSpecId, schema, newPartitionSpec)); + PartitionSpec freshSpec = freshSpecWithAssignIds(newDefaultSpecId, schema, schema, newPartitionSpec, + nextPartitionFieldId, partitionFieldIdByColumnName); Review comment: I think this should work like `updateSchema`, where a different class is responsible for reassigning IDs. The `TableMetadata` class should validate consistency and help with tracking (like the snapshot log) but it shouldn't modify other objects that are passed in, like schemas, snapshots, and partition specs. ---------------------------------------------------------------- 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