RussellSpitzer commented on code in PR #12824:
URL: https://github.com/apache/iceberg/pull/12824#discussion_r2059257480


##########
spark/v3.5/spark/src/test/java/org/apache/iceberg/spark/actions/TestRewriteDataFilesAction.java:
##########
@@ -2011,6 +2011,40 @@ public void testZOrderRewriteWithSpecificOutputSpecId() {
     shouldRewriteDataFilesWithPartitionSpec(table, outputSpecId);
   }
 
+  @TestTemplate
+  public void testRewriteMaxFilesOption() {
+    Table table = createTablePartitioned(5, 4);
+    shouldHaveFiles(table, 20);
+    int desiredMaxFileCount = 5000;
+    Result result =
+        actions()
+            .rewriteDataFiles(table)
+            .option(RewriteDataFiles.MAX_FILES_TO_REWRITE, 
String.valueOf(desiredMaxFileCount))
+            .execute();
+    table.refresh();
+    int filesReWritten = result.rewrittenDataFilesCount();
+    assertThat(filesReWritten).isLessThanOrEqualTo(desiredMaxFileCount);
+  }
+
+  @TestTemplate
+  public void testRewriteMaxFilesOptionEquality() {
+    Table table = createTablePartitioned(5, 4);
+    writeRecords(1, SCALE, 1);
+    writeRecords(2, SCALE, 2);
+    writeRecords(3, SCALE, 3);
+    writeRecords(4, SCALE, 4);
+    shouldHaveFiles(table, 50);
+    int desiredMaxFileCount = 10;
+    Result result =
+        actions()
+            .rewriteDataFiles(table)
+            .option(RewriteDataFiles.MAX_FILES_TO_REWRITE, "10")
+            .execute();
+    table.refresh();
+    int filesReWritten = result.rewrittenDataFilesCount();
+    assertThat(filesReWritten).isEqualTo(desiredMaxFileCount);
+  }
+

Review Comment:
   We are also missing a test where max files to rewrite causes any early 
termination within a partition I think. For example a table with a single 
partition with 7 files and max_files_to_rewrite = 10. I think the code above 
for subList will break here since the index I think has to be within the list 
itself? I haven't checked



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to