aokolnychyi commented on code in PR #6304: URL: https://github.com/apache/iceberg/pull/6304#discussion_r1034133132
########## core/src/main/java/org/apache/iceberg/util/TableScanUtil.java: ########## @@ -151,38 +153,68 @@ public static <T extends PartitionScanTask> List<ScanTaskGroup<T>> planTaskGroup Function<T, Long> weightFunc = task -> Math.max(task.sizeBytes(), task.filesCount() * openFileCost); - Map<Integer, StructProjection> projectionsBySpec = Maps.newHashMap(); + Map<Integer, StructProjection> groupingKeyProjectionsBySpec = Maps.newHashMap(); - // Group tasks by their partition values - StructLikeMap<List<T>> tasksByPartition = StructLikeMap.create(projectedPartitionType); + // group tasks by grouping keys derived from their partition tuples + StructLikeMap<List<T>> tasksByGroupingKey = StructLikeMap.create(groupingKeyType); for (T task : tasks) { PartitionSpec spec = task.spec(); - StructProjection projectedStruct = - projectionsBySpec.computeIfAbsent( + StructProjection groupingKeyProjection = + groupingKeyProjectionsBySpec.computeIfAbsent( spec.specId(), - specId -> StructProjection.create(spec.partitionType(), projectedPartitionType)); - List<T> taskList = - tasksByPartition.computeIfAbsent( - projectedStruct.copyFor(task.partition()), k -> Lists.newArrayList()); Review Comment: We were using `StructProjection` that lazily projects values. However, it is not serializable. That's why I can't pass it into task groups. Instead of creating a copy of the projection, I eagerly project values into `PartitionData`. See `projectGroupingKey` below. -- 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