lasdf1234 commented on code in PR #11219:
URL: https://github.com/apache/gravitino/pull/11219#discussion_r3307832511


##########
iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/CatalogWrapperForREST.java:
##########
@@ -454,62 +452,26 @@ public PlanTableScanResponse planTableScan(
         return cachedResponse.get();
       }
 
-      List<String> planTasks = new ArrayList<>();
-      Map<Integer, PartitionSpec> specsById = new HashMap<>();
-      List<DeleteFile> deleteFiles = new ArrayList<>();
+      List<FileScanTask> fileScanTasksList = new ArrayList<>();
 
       try (CloseableIterable<FileScanTask> fileScanTasks =
           createFilePlanScanTasks(table, tableIdentifier, scanRequest)) {
         for (FileScanTask fileScanTask : fileScanTasks) {
-          try {
-            String taskString = ScanTaskParser.toJson(fileScanTask);
-            planTasks.add(taskString);
-
-            int specId = fileScanTask.spec().specId();
-            if (!specsById.containsKey(specId)) {
-              specsById.put(specId, fileScanTask.spec());
-            }
-
-            if (!fileScanTask.deletes().isEmpty()) {
-              deleteFiles.addAll(fileScanTask.deletes());
-            }
-          } catch (Exception e) {
-            throw new RuntimeException(
-                String.format(
-                    "Failed to serialize scan task for table: %s. Error: %s",
-                    tableIdentifier, e.getMessage()),
-                e);
-          }
+          fileScanTasksList.add(fileScanTask);
         }
       } catch (IOException e) {
         LOG.error("Failed to close scan task iterator for table: {}", 
tableIdentifier, e);
         throw new RuntimeException("Failed to plan scan tasks: " + 
e.getMessage(), e);
       }
 
-      List<DeleteFile> uniqueDeleteFiles =
-          deleteFiles.stream().distinct().collect(Collectors.toList());
-
-      if (planTasks.isEmpty()) {
+      if (fileScanTasksList.isEmpty()) {
         LOG.info(
             "Scan planning returned no tasks for table: {}. Table may be empty 
or fully filtered.",
             tableIdentifier);
       }
 
-      PlanTableScanResponse.Builder responseBuilder =
-          PlanTableScanResponse.builder()
-              .withPlanStatus(PlanStatus.COMPLETED)
-              .withPlanTasks(planTasks)
-              .withSpecsById(specsById);
-
-      if (!uniqueDeleteFiles.isEmpty()) {
-        responseBuilder.withDeleteFiles(uniqueDeleteFiles);
-        LOG.debug(
-            "Included {} delete files in scan plan for table: {}",
-            uniqueDeleteFiles.size(),
-            tableIdentifier);
-      }
-
-      PlanTableScanResponse response = responseBuilder.build();
+      PlanTableScanResponse response =
+          buildCompletedPlanTableScanResponse(fileScanTasksList, 
table.specs());

Review Comment:
   fixed



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

Reply via email to