You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2022/04/18 17:08:06 UTC
[GitHub] [iceberg] RussellSpitzer commented on a diff in pull request #4560: Core: Fix Partitions table for evolved partition specs
RussellSpitzer commented on code in PR #4560:
URL: https://github.com/apache/iceberg/pull/4560#discussion_r852263792
##########
core/src/main/java/org/apache/iceberg/PartitionsTable.java:
##########
@@ -93,16 +94,38 @@ private static StaticDataTask.Row convertPartition(Partition partition) {
return StaticDataTask.Row.of(partition.key, partition.recordCount, partition.fileCount, partition.specId);
}
- private static Iterable<Partition> partitions(StaticTableScan scan) {
+ private static Iterable<Partition> partitions(Table table, StaticTableScan scan) {
CloseableIterable<FileScanTask> tasks = planFiles(scan);
- PartitionMap partitions = new PartitionMap(scan.table().spec().partitionType());
+ PartitionMap partitions = new PartitionMap(Partitioning.partitionType(table));
for (FileScanTask task : tasks) {
- partitions.get(task.file().partition()).update(task.file());
+ PartitionData original = (PartitionData) task.file().partition();
+ PartitionData normalized = normalizePartition(original, Partitioning.partitionType(table));
+ partitions.get(normalized).update(task.file());
}
return partitions.all();
}
+ private static PartitionData normalizePartition(PartitionData partition, Types.StructType newSchema) {
+ Preconditions.checkArgument(partition.getPartitionType().fields().size() == partition.size(),
+ "Partition values must match size");
+ Map<Integer, Object> fieldIdToValues = Maps.newHashMap();
+ int originalPartitionIndex = 0;
+ for (Types.NestedField f : partition.getPartitionType().fields()) {
+ fieldIdToValues.put(f.fieldId(), partition.get(originalPartitionIndex));
+ originalPartitionIndex++;
+ }
+
+ PartitionData result = new PartitionData(newSchema);
Review Comment:
result -> normalizedPartition?
--
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.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org