RussellSpitzer commented on a change in pull request #1313:
URL: https://github.com/apache/iceberg/pull/1313#discussion_r467941219



##########
File path: 
spark/src/test/java/org/apache/iceberg/actions/TestRemoveOrphanFilesAction.java
##########
@@ -569,4 +569,39 @@ public void testRemoveOrphanFilesWithHadoopCatalog() 
throws InterruptedException
         .collectAsList();
     Assert.assertEquals("Rows must match", records, actualRecords);
   }
+
+  @Test
+  public void testRemoveOrphanFilesWithExecutorParallel() {
+    Table table = TABLES.create(SCHEMA, PartitionSpec.unpartitioned(), 
Maps.newHashMap(), tableLocation);
+
+    List<ThreeColumnRecord> records = Lists.newArrayList(
+        new ThreeColumnRecord(1, "AAAAAAAAAA", "AAAA")
+    );
+
+    Dataset<Row> df = spark.createDataFrame(records, 
ThreeColumnRecord.class).coalesce(1);
+
+    df.select("c1", "c2", "c3")
+        .write()
+        .format("iceberg")
+        .mode("append")
+        .save(tableLocation);
+
+    for (int i = 0; i < 20; i++) {
+      df.write().mode("append").parquet(tableLocation + "/data");
+    }
+
+    Actions actions = Actions.forTable(table);
+
+    List<String> result = actions.removeOrphanFiles()
+        .olderThan(System.currentTimeMillis())
+        .executorParallelNum(10)
+        .execute();
+    Assert.assertEquals("Should delete only 20 files", 20, result.size());
+
+    // gets the number of tasks completed by the last stage
+    int completedTasks = spark.sparkContext().statusTracker()
+        .getStageInfo(23).get().numCompletedTasks();

Review comment:
       If the test here is just to determine the number of partitions in the 
RDD it's probably safer to expose that as a package protected member of the 
class and call .partitions. The magic number here is going to be brittle. 
   
   One fun little game you could also play here to count tasks that were run, 
would be to implement another "DeleteConsumer" that just uses an accumulator 
and just add's 1 on each forEachParititon. 




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

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