deniskuzZ commented on code in PR #12137:
URL: https://github.com/apache/iceberg/pull/12137#discussion_r1961671738


##########
core/src/main/java/org/apache/iceberg/PartitionStatsUtil.java:
##########
@@ -96,7 +96,10 @@ private static PartitionMap<PartitionStats> collectStats(
         StructLike key = keyTemplate.copyFor(coercedPartition);
         Snapshot snapshot = table.snapshot(entry.snapshotId());
         PartitionStats stats =
-            statsMap.computeIfAbsent(specId, key, () -> new 
PartitionStats(key, specId));
+            statsMap.computeIfAbsent(
+                specId,
+                ((PartitionData) file.partition()).copy(),

Review Comment:
   hi @pvary, thanks for taking a look.
   `keyTemplate` is of unified tuple struct, so it can't be used. btw, if you 
grep iceberg code, you'll find a number of same casts.
   I can introduce `toPartitionData` helper method, if you think that would be 
better
   ````
     public static PartitionData toPartitionData(StructLike key, 
Types.StructType keyType) {
       PartitionData keyTemplate = new PartitionData(keyType);
       return keyTemplate.copyFor(key);
     }
   ````



##########
core/src/main/java/org/apache/iceberg/PartitionStatsUtil.java:
##########
@@ -96,7 +96,10 @@ private static PartitionMap<PartitionStats> collectStats(
         StructLike key = keyTemplate.copyFor(coercedPartition);
         Snapshot snapshot = table.snapshot(entry.snapshotId());
         PartitionStats stats =
-            statsMap.computeIfAbsent(specId, key, () -> new 
PartitionStats(key, specId));
+            statsMap.computeIfAbsent(
+                specId,
+                ((PartitionData) file.partition()).copy(),

Review Comment:
   hi @pvary, thanks for taking a look.
   `keyTemplate` is of unified tuple struct, so it can't be used. btw, if you 
grep iceberg code, you'll find a number of same casts.
   
   I can introduce `toPartitionData` helper method, if you think that would be 
better
   ````
     public static PartitionData toPartitionData(StructLike key, 
Types.StructType keyType) {
       PartitionData keyTemplate = new PartitionData(keyType);
       return keyTemplate.copyFor(key);
     }
   ````



-- 
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-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to