singhpk234 commented on code in PR #14480:
URL: https://github.com/apache/iceberg/pull/14480#discussion_r2485447796


##########
core/src/test/java/org/apache/iceberg/rest/RESTCatalogAdapter.java:
##########
@@ -294,6 +320,113 @@ public <T extends RESTResponse> T handleRequest(
           return castResponse(responseType, response);
         }
 
+      case PLAN_TABLE_SCAN:
+        {
+          TableIdentifier ident = tableIdentFromPathVars(vars);
+          PlanTableScanRequest request = 
castRequest(PlanTableScanRequest.class, body);
+          Table table = catalog.loadTable(ident);
+          TableScan tableScan = table.newScan();
+
+          if (request.snapshotId() != null) {
+            tableScan = tableScan.useSnapshot(request.snapshotId());
+          }
+          if (request.select() != null) {
+            tableScan = tableScan.select(request.select());
+          }
+          if (request.filter() != null) {
+            tableScan = tableScan.filter(request.filter());
+          }
+          if (request.statsFields() != null) {
+            tableScan = tableScan.includeColumnStats(request.statsFields());
+          }
+
+          tableScan = tableScan.caseSensitive(request.caseSensitive());
+
+          if (planningBehavior.shouldPlanTableScanAsync(tableScan)) {
+            String asyncPlanId = UUID.randomUUID().toString();
+            asyncPlanFiles(tableScan, asyncPlanId);
+            return castResponse(
+                responseType,
+                PlanTableScanResponse.builder()
+                    .withPlanId(asyncPlanId)
+                    .withPlanStatus(PlanStatus.SUBMITTED)
+                    .withSpecsById(table.specs())
+                    .build());
+          }
+
+          String planId = UUID.randomUUID().toString();
+          planFilesFor(tableScan, planId);
+          Pair<List<FileScanTask>, String> tasksAndPlan = 
initialScanTasksForPlan(planId);
+          return castResponse(
+              responseType,
+              PlanTableScanResponse.builder()
+                  .withPlanStatus(PlanStatus.COMPLETED)
+                  .withPlanTasks(nextPlanTasks(tasksAndPlan.second()))
+                  .withFileScanTasks(tasksAndPlan.first())
+                  .withDeleteFiles(
+                      tasksAndPlan.first().stream()
+                          .flatMap(t -> t.deletes().stream())
+                          .distinct()
+                          .collect(Collectors.toList()))
+                  .withSpecsById(table.specs())
+                  .build());
+        }
+
+      case FETCH_PLANNING_RESULT:
+        {
+          TableIdentifier ident = tableIdentFromPathVars(vars);
+          Table table = catalog.loadTable(ident);
+          String planId = planIDFromPathVars(vars);
+          Pair<List<FileScanTask>, String> tasksAndPlan = 
initialScanTasksForPlan(planId);
+          return castResponse(
+              responseType,
+              FetchPlanningResultResponse.builder()
+                  .withPlanStatus(PlanStatus.COMPLETED)
+                  .withDeleteFiles(
+                      tasksAndPlan.first().stream()
+                          .flatMap(t -> t.deletes().stream())
+                          .distinct()
+                          .collect(Collectors.toList()))
+                  .withFileScanTasks(tasksAndPlan.first())
+                  .withPlanTasks(nextPlanTasks(tasksAndPlan.second()))
+                  .withSpecsById(table.specs())
+                  .build());
+        }
+
+      case FETCH_SCAN_TASKS:
+        {
+          TableIdentifier ident = tableIdentFromPathVars(vars);
+          Table table = catalog.loadTable(ident);
+          FetchScanTasksRequest request = 
castRequest(FetchScanTasksRequest.class, body);
+          String planTask = request.planTask();
+          List<FileScanTask> fileScanTasks = 
planTaskToFileScanTasks.get(planTask);
+          if (fileScanTasks == null) {
+            throw new NoSuchPlanTaskException("Could not find tasks for plan 
task %s", planTask);
+          }
+
+          // Simple implementation, only have at most 1 "next" plan task to 
simulate pagination
+          return castResponse(
+              responseType,
+              FetchScanTasksResponse.builder()
+                  .withFileScanTasks(fileScanTasks)
+                  .withPlanTasks(nextPlanTasks(planTask))
+                  .withSpecsById(table.specs())

Review Comment:
   reduced the visibility of this API from public to protected, at the same 
time made the response model which were created post deserialization also to 
contain the specs-by-id for completion.
   please let me know your thoughts 



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