singhpk234 commented on code in PR #13400:
URL: https://github.com/apache/iceberg/pull/13400#discussion_r2361678732
##########
core/src/test/java/org/apache/iceberg/rest/RESTCatalogAdapter.java:
##########
@@ -434,6 +469,169 @@ 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.useSnapshot(request.snapshotId());
+ }
+ if (request.select() != null) {
+ tableScan.select(request.select());
+ }
+ if (request.filter() != null) {
+ tableScan.filter(request.filter());
+ }
+ if (request.statsFields() != null) {
+ tableScan.includeColumnStats(request.statsFields());
+ }
+ tableScan.caseSensitive(request.caseSensitive());
+
+ List<FileScanTask> fileScanTasks = Lists.newArrayList();
+ CloseableIterable<FileScanTask> returnedTasks =
tableScan.planFiles();
+ returnedTasks.forEach(task -> fileScanTasks.add(task));
+
+ if (ident.equals(TABLE_COMPLETED_WITH_FILE_SCAN_TASK)) {
+ return castResponse(
+ responseType,
+ PlanTableScanResponse.builder()
+ .withPlanStatus(PlanStatus.COMPLETED)
+ .withFileScanTasks(fileScanTasks)
+ .withDeleteFiles(
+ fileScanTasks.stream()
+ .flatMap(t -> t.deletes().stream())
+ .distinct()
+ .collect(Collectors.toList()))
+ .withSpecsById(table.specs())
+ .build());
+ }
+
+ if (ident.equals(TABLE_SUBMITTED_WITH_FILE_SCAN_TASK)) {
+ // this is the case where we return a plan-id, then call
fetchPlanningResult to get the
+ // tasks at a later point
+ String planId = "plan-id-" + UUID.randomUUID();
+ planToFileScanTasks.put(planId, fileScanTasks);
+ return castResponse(
+ responseType,
+ PlanTableScanResponse.builder()
+ .withPlanId(planId)
+ .withPlanStatus(PlanStatus.SUBMITTED)
+ .withSpecsById(table.specs())
+ .build());
+ }
+
+ if (ident.equals(TABLE_COMPLETED_WITH_PLAN_TASK)) {
+ // this is the case where we return a list of plan-task, and then
call fetchScanTasks
+ // for each
+ List<String> planTasks =
+ List.of("plan-task-" + UUID.randomUUID(), "plan-task-" +
UUID.randomUUID());
+ planTasks.forEach(task -> planToFileScanTasks.put(task,
fileScanTasks));
+ return castResponse(
+ responseType,
+ PlanTableScanResponse.builder()
+ .withPlanStatus(PlanStatus.COMPLETED)
+ .withPlanTasks(planTasks)
+ .withDeleteFiles(
+ fileScanTasks.stream()
+ .flatMap(t -> t.deletes().stream())
+ .distinct()
+ .collect(Collectors.toList()))
Review Comment:
This is something that was not intentional ideally the planTasks should be
able to infers Deletes could have been abstracted from the planTasks itself
(this may be confusing), may be we need to update the Request / Response model
for this.
--
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]