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


##########
core/src/test/java/org/apache/iceberg/rest/TestRESTCatalog.java:
##########
@@ -3163,4 +3350,411 @@ private static List<HTTPRequest> 
allRequests(RESTCatalogAdapter adapter) {
     verify(adapter, atLeastOnce()).execute(captor.capture(), any(), any(), 
any());
     return captor.getAllValues();
   }
+
+  @Test
+  public void testCancelPlanMethodAvailability() {
+    
configurePlanningBehavior(TestPlanningBehavior.Builder::synchronousWithPagination);
+    RESTTable table = restTableFor("cancel_method_table");
+    RESTTableScan restTableScan = restTableScanFor(table);
+
+    // Test that cancelPlan method is available and callable
+    // When no plan is active, it should return false
+    assertThat(restTableScan.cancelPlan()).isFalse();
+
+    // Verify the method exists and doesn't throw exceptions when called 
multiple times
+    assertThat(restTableScan.cancelPlan()).isFalse();
+  }
+
+  @ParameterizedTest
+  @EnumSource(MetadataTableType.class)
+  public void testMetadataTablesWithRemotePlanning(MetadataTableType type) {
+    // POSITION_DELETES table does not implement newScan() method
+    assumeThat(type).isNotEqualTo(MetadataTableType.POSITION_DELETES);
+
+    configurePlanningBehavior(TestPlanningBehavior.Builder::synchronous);
+    RESTTable table = restTableFor("metadata_tables_test");
+    table.newAppend().appendFile(FILE_B).commit();
+    
table.newRowDelta().addDeletes(FILE_A_DELETES).addDeletes(FILE_B_EQUALITY_DELETES).commit();
+    setParserContext(table);
+    Table metadataTableInstance = 
MetadataTableUtils.createMetadataTableInstance(table, type);
+    assertThat(metadataTableInstance).isNotNull();
+
+    TableScan metadataTableScan = metadataTableInstance.newScan();
+    CloseableIterable<FileScanTask> metadataTableIterable = 
metadataTableScan.planFiles();
+    List<FileScanTask> tasks = Lists.newArrayList(metadataTableIterable);
+    assertThat(tasks).isNotEmpty();
+  }
+
+  @Test
+  public void testIterableCloseTriggersCancel() throws IOException {
+    configurePlanningBehavior(TestPlanningBehavior.Builder::asynchronous);
+    RESTTable restTable = restTableFor("iterable_close_test");
+    setParserContext(restTable);
+
+    TableScan scan = restTable.newScan();
+    assertThat(scan).isInstanceOf(RESTTableScan.class);
+    RESTTableScan restTableScan = (RESTTableScan) scan;
+
+    // Get the iterable
+    CloseableIterable<FileScanTask> iterable = restTableScan.planFiles();
+
+    // call cancelPlan before closing the iterable
+    boolean cancelled = restTableScan.cancelPlan();
+    assertThat(cancelled).isTrue();
+
+    // Verify we can close the iterable without exceptions
+    // This tests that cancellation callbacks are properly wired through
+    iterable.close();
+  }
+
+  @Test
+  @Disabled("Pending fix for the RESTCatalogAdapter to support empty tables")
+  public void remoteScanPlanningWithEmptyTable() throws IOException {
+    configurePlanningBehavior(TestPlanningBehavior.Builder::synchronous);
+    Table table = createTableWithScanPlanning("empty_table_test");
+    setParserContext(table);
+
+    // Execute scan planning on empty table
+    try (CloseableIterable<FileScanTask> iterable = 
table.newScan().planFiles()) {
+      List<FileScanTask> tasks = Lists.newArrayList(iterable);
+
+      // Verify no tasks are returned for empty table
+      assertThat(tasks).isEmpty();
+    }
+  }
+
+  @Test
+  @Disabled("Pruning files based on columns is not yet supported in REST scan 
planning")

Review Comment:
   This is not supported by client side planning itself as well, gonna take a 
long time 



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