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


##########
iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/CatalogWrapperForREST.java:
##########
@@ -484,6 +492,46 @@ public PlanTableScanResponse planTableScan(
     }
   }
 
+  /**
+   * Fetch the scan tasks associated with a {@code plan-task} token previously 
handed out by {@link
+   * #planTableScan}.
+   *
+   * <p>Scan planning here is synchronous: {@link #planTableScan} always 
returns {@code COMPLETED}
+   * with the full set of {@code file-scan-tasks} inline and never emits 
{@code plan-tasks} tokens.
+   * A client therefore has no token to present, and any token reaching this 
method did not
+   * originate from this server (or came from a server generation that no 
longer retains it). Per
+   * the Iceberg REST specification that case is an unknown plan task, so this 
method always throws
+   * {@link NoSuchPlanTaskException}, which the REST layer maps to 404.
+   *
+   * <p>The endpoint still exists and is advertised in {@code /v1/config} 
because clients such as
+   * pyiceberg refuse to use server-side scan planning at all unless {@code 
POST
+   * .../tables/{table}/tasks} is advertised as supported. Implementing it 
keeps the two-step
+   * protocol contract intact and gives batched planning a place to land if 
{@link #planTableScan}
+   * later starts emitting {@code plan-tasks}.
+   *
+   * @param tableIdentifier the table the plan task belongs to.
+   * @param request the request carrying the {@code plan-task} token.
+   * @return never returns normally.
+   * @throws org.apache.iceberg.exceptions.NoSuchTableException if the table 
doesn't exist.
+   * @throws NoSuchPlanTaskException always, since no {@code plan-task} tokens 
are ever issued.
+   */
+  public FetchScanTasksResponse fetchScanTasks(
+      TableIdentifier tableIdentifier, FetchScanTasksRequest request) {
+    // Validate the table exists first, so a bad table reports 404 for the 
table rather than
+    // masking it as an unknown plan task. Consistent with planTableScan 
behavior.
+    getCatalog().loadTable(tableIdentifier);
+
+    LOG.info(
+        "Rejecting unknown plan task '{}' for table {}: scan planning is 
synchronous and does not "
+            + "issue plan-task tokens.",
+        request.planTask(),
+        tableIdentifier);
+    throw new NoSuchPlanTaskException(

Review Comment:
   @laserninja May be you should implement this method and update your PR's 
description.



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