RussellSpitzer commented on code in PR #12824: URL: https://github.com/apache/iceberg/pull/12824#discussion_r2067326299
########## spark/v3.5/spark/src/test/java/org/apache/iceberg/spark/actions/TestRewriteDataFilesAction.java: ########## @@ -2011,6 +2011,68 @@ 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); + } + + @TestTemplate + public void testRewriteMaxFilesOptionSinglePartition() { Review Comment: nit: This is testing testMaxFilesGreaterThanFileCount I would also like if we can add another test with 2 partitions and max files to rewrite only truncating on one of them. Ie Partition 1 and 2 both have seven files. Should rewrite only 10 files but only take 3 of the second partition. -- 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