huaxingao commented on code in PR #15096:
URL: https://github.com/apache/iceberg/pull/15096#discussion_r2718329690


##########
core/src/test/java/org/apache/iceberg/rest/TestRESTScanPlanning.java:
##########
@@ -229,6 +239,74 @@ private void configurePlanningBehavior(
     
adapterForRESTServer.setPlanningBehavior(configurator.apply(builder).build());
   }
 
+  private String planPath(TableIdentifier ident) {
+    return String.format(
+        "v1/namespaces/%s/tables/%s/plan",
+        RESTUtil.encodeNamespace(ident.namespace(), 
RESTUtil.NAMESPACE_SEPARATOR_URLENCODED_UTF_8),
+        RESTUtil.encodeString(ident.name()));
+  }
+
+  private String tasksPath(TableIdentifier ident) {
+    return String.format(
+        "v1/namespaces/%s/tables/%s/tasks",
+        RESTUtil.encodeNamespace(ident.namespace(), 
RESTUtil.NAMESPACE_SEPARATOR_URLENCODED_UTF_8),
+        RESTUtil.encodeString(ident.name()));
+  }
+
+  private String cancelPath(TableIdentifier ident, String planId) {
+    return String.format(
+        "v1/namespaces/%s/tables/%s/plan/%s",
+        RESTUtil.encodeNamespace(ident.namespace(), 
RESTUtil.NAMESPACE_SEPARATOR_URLENCODED_UTF_8),
+        RESTUtil.encodeString(ident.name()),
+        RESTUtil.encodeString(planId));
+  }

Review Comment:
   Fixed. Thanks!



##########
core/src/test/java/org/apache/iceberg/rest/TestRESTScanPlanning.java:
##########
@@ -1040,4 +1118,135 @@ public void serverSupportsPlanningButNotCancellation() 
throws IOException {
     // Verify no exception was thrown - cancelPlan returns false when endpoint 
not supported
     assertThat(cancelled).isFalse();
   }
+
+  @Test
+  public void planTableScanReplaysResponseForSameIdempotencyKey() {
+    configurePlanningBehavior(TestPlanningBehavior.Builder::asynchronous);
+
+    TableIdentifier ident = TableIdentifier.of(NS, "idempotent_plan_scan");
+    Table table = createTableWithScanPlanning(scanPlanningCatalog(), ident);
+    setParserContext(table);
+
+    Map<String, String> headers = 
idempotencyHeader("test-idempotency-key-planTableScan");
+    PlanTableScanRequest request = defaultPlanRequest();
+
+    List<PlanTableScanResponse> responses =
+        executeTwice(
+            HTTPRequest.HTTPMethod.POST,
+            planPath(ident),
+            headers,
+            request,
+            PlanTableScanResponse.class,
+            ErrorHandlers.tableErrorHandler());
+    PlanTableScanResponse first = responses.get(0);
+    PlanTableScanResponse second = responses.get(1);

Review Comment:
   Agreed `executeTwice` doesn’t really reduce verbosity here. I’ve updated the 
test to use two explicit execute(...) calls for first and second to make the 
two invocations unambiguous



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