rdblue commented on code in PR #18108:
URL: https://github.com/apache/iceberg/pull/18108#discussion_r4021293025
##########
core/src/main/java/org/apache/iceberg/TrackedFileStruct.java:
##########
@@ -210,14 +216,55 @@ public long fileSizeInBytes() {
return fileSizeInBytes;
}
+ void setSpecsById(Map<Integer, PartitionSpec> newSpecsById) {
+ this.specsById = newSpecsById;
+ }
+
@Override
public Integer specId() {
return specId;
}
@Override
public StructLike partition() {
- return partitionData;
+ if (partitionData == null || specId == null || specsById == null) {
+ return partitionData;
+ }
+
+ StructProjection projection = partitionProjection(specId);
+ return projection != null ? projection.wrap(partitionData) : partitionData;
+ }
+
+ private StructProjection partitionProjection(int id) {
+ if (partitionProjections == null) {
+ this.partitionProjections = Maps.newHashMap();
+ }
+
+ if (!partitionProjections.containsKey(id)) {
+ PartitionSpec spec = specsById.get(id);
+ Types.StructType specType = spec != null ? spec.partitionType() : null;
+ // null when the stored tuple already matches the spec, so partition()
passes it through
+ partitionProjections.put(
+ id,
+ specType == null || partitionData.getPartitionType().equals(specType)
+ ? null
+ : StructProjection.create(partitionData.getPartitionType(),
specType));
+ }
+
+ return partitionProjections.get(id);
+ }
+
+ private PartitionData materializedPartition() {
Review Comment:
I think this class should use `StructUtil.copy(partition())`. There's no
need to ensure that the result is a `PartitionData`. Won't any `StructLike`
work?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]