-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Core: Add max-file-group-input-files to valid rewrite options #17544
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -175,6 +175,41 @@ void testMaxGroupSize() { | |
| assertThat(plan.groupsInPartition(FILE_6.partition())).isEqualTo(1); | ||
| } | ||
|
|
||
| @Test | ||
| void testMaxFileGroupInputFiles() { | ||
| addFiles(); | ||
| // First, establish baseline without the constraint | ||
| BinPackRewriteFilePlanner baselinePlanner = new BinPackRewriteFilePlanner(table); | ||
| baselinePlanner.init(REWRITE_ALL); | ||
| FileRewritePlan<FileGroupInfo, FileScanTask, DataFile, RewriteFileGroup> baselinePlan = | ||
| baselinePlanner.plan(); | ||
| int baselineGroupCount = baselinePlan.totalGroupCount(); | ||
| int baselineGroupsInPartition0 = baselinePlan.groupsInPartition(FILE_1.partition()); | ||
|
|
||
| // Now test with max-file-group-input-files set to 2, which limits each group to 2 files | ||
| // Partition 0 has 3 files (FILE_1, FILE_2, FILE_3), so it should be split into 2 groups | ||
| // Partition 1 has 2 files (FILE_4, FILE_5), so it should be 1 group | ||
| // Partition 2 has 1 file (FILE_6), so it should be 1 group | ||
| BinPackRewriteFilePlanner constrainedPlanner = new BinPackRewriteFilePlanner(table); | ||
| constrainedPlanner.init( | ||
| ImmutableMap.of( | ||
| BinPackRewriteFilePlanner.REWRITE_ALL, | ||
| "true", | ||
| BinPackRewriteFilePlanner.MAX_FILE_GROUP_INPUT_FILES, | ||
| "2")); | ||
|
|
||
| FileRewritePlan<FileGroupInfo, FileScanTask, DataFile, RewriteFileGroup> constrainedPlan = | ||
| constrainedPlanner.plan(); | ||
|
|
||
| // Verify the constraint is honored: should have MORE groups when input files are limited | ||
| assertThat(constrainedPlan.totalGroupCount()).isGreaterThan(baselineGroupCount).isEqualTo(4); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the
|
||
| assertThat(constrainedPlan.groupsInPartition(FILE_1.partition())) | ||
| .isGreaterThan(baselineGroupsInPartition0) | ||
| .isEqualTo(2); | ||
| assertThat(constrainedPlan.groupsInPartition(FILE_4.partition())).isEqualTo(1); | ||
| assertThat(constrainedPlan.groupsInPartition(FILE_6.partition())).isEqualTo(1); | ||
| } | ||
|
|
||
| @Test | ||
| void testFilter() { | ||
| addFiles(); | ||
|
|
@@ -289,6 +324,7 @@ void testValidOptions() { | |
| BinPackRewriteFilePlanner.MIN_INPUT_FILES, | ||
| BinPackRewriteFilePlanner.REWRITE_ALL, | ||
| BinPackRewriteFilePlanner.MAX_FILE_GROUP_SIZE_BYTES, | ||
| BinPackRewriteFilePlanner.MAX_FILE_GROUP_INPUT_FILES, | ||
| BinPackRewriteFilePlanner.DELETE_FILE_THRESHOLD, | ||
| BinPackRewriteFilePlanner.DELETE_RATIO_THRESHOLD, | ||
| RewriteDataFiles.REWRITE_JOB_ORDER, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -103,7 +103,8 @@ void testValidOptions() { | |
| BinPackRewriteFilePlanner.MAX_FILE_SIZE_BYTES, | ||
| BinPackRewriteFilePlanner.MIN_INPUT_FILES, | ||
| BinPackRewriteFilePlanner.REWRITE_ALL, | ||
| BinPackRewriteFilePlanner.MAX_FILE_GROUP_SIZE_BYTES)); | ||
| BinPackRewriteFilePlanner.MAX_FILE_GROUP_SIZE_BYTES, | ||
| BinPackRewriteFilePlanner.MAX_FILE_GROUP_INPUT_FILES)); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. while we're adding this to the valid set — |
||
| } | ||
|
|
||
| @Test | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1486,6 +1486,26 @@ public void testInvalidOptions() { | |
| .hasMessageContaining("requires enabling Iceberg Spark session extensions"); | ||
| } | ||
|
|
||
| @TestTemplate | ||
| public void testMaxFileGroupInputFilesOption() { | ||
| Table table = createTable(4); | ||
| shouldHaveFiles(table, 4); | ||
|
|
||
| List<Object[]> originalData = currentData(); | ||
| long dataSizeBefore = testDataSize(table); | ||
|
|
||
| RewriteDataFiles.Result result = | ||
| basicRewrite(table) | ||
| .option(SizeBasedFileRewritePlanner.MAX_FILE_GROUP_INPUT_FILES, "2") | ||
| .execute(); | ||
|
|
||
| assertThat(result.rewriteResults()).as("Action should rewrite file groups").isNotEmpty(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this asserts the option is accepted, but not that it does anything — 4 files landing in a single group is also non-empty, so a regression where With 4 unpartitioned files and a limit of 2 the grouping is deterministic (2 groups), so I'd assert |
||
| assertThat(result.rewrittenBytesCount()).isEqualTo(dataSizeBefore); | ||
|
|
||
| table.refresh(); | ||
| assertEquals("Rows must match", originalData, currentData()); | ||
| } | ||
|
|
||
| @TestTemplate | ||
| public void testSortMultipleGroups() { | ||
| Table table = createTable(20); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if there is a better way to run this test