rdblue commented on a change in pull request #1475:
URL: https://github.com/apache/iceberg/pull/1475#discussion_r493724034
##########
File path: core/src/main/java/org/apache/iceberg/TableMetadata.java
##########
@@ -622,32 +622,26 @@ public TableMetadata buildReplacement(Schema
updatedSchema, PartitionSpec update
ValidationException.check(formatVersion > 1 ||
PartitionSpec.hasSequentialIds(updatedPartitionSpec),
"Spec does not use sequential IDs that are required in v1: %s",
updatedPartitionSpec);
- AtomicInteger nextLastColumnId = new AtomicInteger(0);
- Schema freshSchema = TypeUtil.assignFreshIds(updatedSchema,
nextLastColumnId::incrementAndGet);
+ AtomicInteger newLastColumnId = new AtomicInteger(lastColumnId);
+ Schema freshSchema = TypeUtil.assignFreshIds(updatedSchema, schema,
newLastColumnId::incrementAndGet);
- int nextSpecId = TableMetadata.INITIAL_SPEC_ID;
- for (Integer specId : specsById.keySet()) {
- if (nextSpecId <= specId) {
- nextSpecId = specId + 1;
- }
- }
+ // determine the next spec id
+ OptionalInt maxSpecId =
specs.stream().mapToInt(PartitionSpec::specId).max();
+ int nextSpecId = maxSpecId.orElse(TableMetadata.INITIAL_SPEC_ID) + 1;
Review comment:
Yes, this simplifies the logic a bit and avoids using spec id 0.
----------------------------------------------------------------
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]