aokolnychyi commented on code in PR #6304: URL: https://github.com/apache/iceberg/pull/6304#discussion_r1034135458
########## 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()); + specId -> StructProjection.create(spec.partitionType(), groupingKeyType)); + List<T> groupingKeyTasks = + tasksByGroupingKey.computeIfAbsent( + projectGroupingKey(groupingKeyProjection, groupingKeyType, task), + groupingKey -> Lists.newArrayList()); if (task instanceof SplittableScanTask<?>) { - ((SplittableScanTask<? extends T>) task).split(splitSize).forEach(taskList::add); + ((SplittableScanTask<? extends T>) task).split(splitSize).forEach(groupingKeyTasks::add); } else { - taskList.add(task); + groupingKeyTasks.add(task); } } - // Now apply task combining within each partition - return FluentIterable.from(tasksByPartition.values()) Review Comment: I need to pass more params around so `FluentIterable` no longer gives concise syntax. -- 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