jun-he commented on a change in pull request #2284:
URL: https://github.com/apache/iceberg/pull/2284#discussion_r609348817
##########
File path: core/src/main/java/org/apache/iceberg/TableMetadata.java
##########
@@ -842,18 +844,42 @@ private static SortOrder updateSortOrderSchema(Schema
schema, SortOrder sortOrde
return builder.build();
}
- private static PartitionSpec freshSpec(int specId, Schema schema,
PartitionSpec partitionSpec) {
+ private static PartitionSpec freshSpec(int specId, Schema schema,
PartitionSpec partitionSpec, int formatVersion,
+ List<PartitionSpec> specs,
AtomicInteger lastPartitionId) {
PartitionSpec.Builder specBuilder = PartitionSpec.builderFor(schema)
.withSpecId(specId);
- 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.add(
- schema.findField(sourceName).fieldId(),
- field.fieldId(),
- field.name(),
- field.transform().toString());
+ if (formatVersion > 1) {
+ Map<Pair<Integer, String>, Integer> transformToFieldId = specs.stream()
+ .flatMap(spec -> spec.fields().stream())
+ .collect(Collectors.toMap(
+ field -> Pair.of(field.sourceId(), field.transform().toString()),
+ PartitionField::fieldId,
+ (n1, n2) -> n2));
+
+ for (PartitionField field : partitionSpec.fields()) {
Review comment:
👌 updated it.
--
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]