aokolnychyi commented on code in PR #7565:
URL: https://github.com/apache/iceberg/pull/7565#discussion_r1194615414


##########
spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/actions/RewritePositionDeleteFilesSparkAction.java:
##########
@@ -133,55 +133,59 @@ public RewritePositionDeleteFiles.Result execute() {
     }
   }
 
-  private Map<StructLike, List<List<PositionDeletesScanTask>>> 
planFileGroups() {
-    Table deletesTable =
-        MetadataTableUtils.createMetadataTableInstance(table, 
MetadataTableType.POSITION_DELETES);
-    CloseableIterable<PositionDeletesScanTask> scanTasks =
-        CloseableIterable.transform(
-            deletesTable.newBatchScan().ignoreResiduals().planFiles(),
-            t -> (PositionDeletesScanTask) t);
+  private StructLikeMap<List<List<PositionDeletesScanTask>>> planFileGroups() {
+    CloseableIterable<PositionDeletesScanTask> fileTasks = planFiles();
 
     try {
       StructType partitionType = Partitioning.partitionType(table);
-      StructLikeMap<List<PositionDeletesScanTask>> filesByPartition =
-          StructLikeMap.create(partitionType);
-
-      for (PositionDeletesScanTask task : scanTasks) {
-        StructLike coerced = coercePartition(task, partitionType);
-
-        List<PositionDeletesScanTask> partitionTasks = 
filesByPartition.get(coerced);
-        if (partitionTasks == null) {
-          partitionTasks = Lists.newArrayList();
-        }
-        partitionTasks.add(task);
-        filesByPartition.put(coerced, partitionTasks);
-      }
+      StructLikeMap<List<PositionDeletesScanTask>> fileTasksByPartition =
+          filesByPartition(partitionType, fileTasks);
 
-      StructLikeMap<List<List<PositionDeletesScanTask>>> fileGroupsByPartition 
=
-          StructLikeMap.create(partitionType);
-
-      filesByPartition.forEach(
-          (partition, partitionTasks) -> {
-            Iterable<List<PositionDeletesScanTask>> plannedFileGroups =
-                rewriter.planFileGroups(partitionTasks);
-            List<List<PositionDeletesScanTask>> groups = 
ImmutableList.copyOf(plannedFileGroups);
-            if (groups.size() > 0) {
-              fileGroupsByPartition.put(partition, groups);
-            }
-          });
-
-      return fileGroupsByPartition;
+      return fileGroupsByPartition(fileTasksByPartition);

Review Comment:
   Optional: Is the empty line above useful?



-- 
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]

Reply via email to