This is an automated email from the ASF dual-hosted git repository.
Gabriel39 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new f6b5f3da164 [fix](fe) Keep oversized Iceberg files in rewrite groups
(#70616)
f6b5f3da164 is described below
commit f6b5f3da1649d46cf7e24a2d020bbd6e64f04354
Author: daidai <[email protected]>
AuthorDate: Mon Nov 23 11:13:51 2026 +0800
[fix](fe) Keep oversized Iceberg files in rewrite groups (#70616)
### Background
Iceberg `rewrite_data_files` first selects candidate data files, packs
them into groups by partition, and filters those groups before executing
rewrites. The maximum accepted file size and the maximum group input
size serve different purposes.
### What problem does this PR solve?
Issue Number: None
Related PR: #56413 (introduced the threshold), #64304 (moved the planner
into the connector)
PR Type: Bugfix
Problem Summary:
A single oversized file can be selected as a candidate and then silently
discarded by group filtering. For example, a 1024-byte file with target
size 512, maximum file size 900 and maximum group size 100000 produces
zero groups with the default file-count and delete settings. Compare
group content against the maximum accepted file size so the file reaches
the rewrite executor, while keeping the group-size setting for bin
packing.
### Details
- **Frequency:** A candidate single-file group exceeds
`max-file-size-bytes`, stays at or below `max-file-group-size-bytes`,
and has no delete-related trigger.
- **Root cause:** `hasTooMuchContent` compares group input against
`getMaxFileGroupSizeBytes()`. Both count/content alternatives require
more than one input file, so lowering `min-input-files` to 1 does not
repair this case.
- **Why existing tests missed it:** The existing oversized-file case
also exceeded the group cap, which made the incorrect comparison
succeed.
- **Fix:** Use `getMaxFileSizeBytes()` for the group-content condition.
Extend existing planner and procedure tests across both selection
layers, using validated options, exact input paths, default settings,
size boundaries, small files and group packing.
- **Other paths and branches:** Backport to branch-4.2 is recommended.
At `0a24ed86fb8da943e43facf653b5a3016470177a`, the [legacy planner still
uses the group-size
threshold](https://github.com/apache/doris/blob/0a24ed86fb8da943e43facf653b5a3016470177a/fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/rewrite/RewriteDataFilePlanner.java#L267).
Its `testFileSizeFiltering` also expects a lone oversized file to be
discarded; update that expectation and adapt coverage to the legacy
constructor and action APIs. This PR targets master.
### Testing
Local validation on 2026-11-12 for head
`e6393478f39cc09d318de5259f19f58740d3e800`:
- `run-fe-ut.sh --run
'RewriteDataFilePlannerTest,IcebergProcedureOpsTest,IcebergRewriteDataFilesActionTest'`:
64 tests passed, zero failures/errors/skips. The same cases fail nine
assertions before the correction.
- `build.sh --fe -j4` with UI disabled: passed, including Checkstyle and
connector architecture gates.
- Real Iceberg planning over synthetic file metadata exercises both
selection layers and the procedure boundary. Physical SQL rewriting,
backend output sizes and performance were not tested.
Publication checks on 2026-11-16: the three affected source/test files
are unchanged on latest master
`f468c7d397ce5c65ad02c62e9f5e0187ba8f950f`, and `git merge-tree
--write-tree` reports a clean merge. The local commit and its validated
source are unchanged; tests were not rerun for publication.
### Release note
Fix Iceberg `rewrite_data_files` skipping a lone file larger than
`max-file-size-bytes` when it is below the group-size limit. The
group-size setting continues to control bin packing.
### Check List (For Author)
- Behavior changed: Yes; oversized singleton groups survive filtering. A
small singleton is no longer rewritten solely because it exceeds a small
packing limit.
- Does this need documentation: Yes; change the group-content threshold
in the website's rewrite file-selection description to
`max-file-size-bytes`.
- Pre-submission status: Partially verified; local FE build and 64
targeted tests passed. Physical SQL/BE rewriting and remote CI remain
unverified. Branch-4.2 backport tests have not been run.
### AI Disclosure
- Tool: OpenAI Codex.
- Generated: Code, unit tests and this description.
- Human review: Pending; the agent performed local self-review.
---
.../iceberg/rewrite/RewriteDataFilePlanner.java | 4 +-
.../connector/iceberg/IcebergProcedureOpsTest.java | 28 ++++++++
.../rewrite/RewriteDataFilePlannerTest.java | 79 ++++++++++++++++++++--
3 files changed, 102 insertions(+), 9 deletions(-)
diff --git
a/fe/fe-connector/fe-connector-iceberg/src/main/java/org/apache/doris/connector/iceberg/rewrite/RewriteDataFilePlanner.java
b/fe/fe-connector/fe-connector-iceberg/src/main/java/org/apache/doris/connector/iceberg/rewrite/RewriteDataFilePlanner.java
index 4a51d43ace9..4f7cc405b5c 100644
---
a/fe/fe-connector/fe-connector-iceberg/src/main/java/org/apache/doris/connector/iceberg/rewrite/RewriteDataFilePlanner.java
+++
b/fe/fe-connector/fe-connector-iceberg/src/main/java/org/apache/doris/connector/iceberg/rewrite/RewriteDataFilePlanner.java
@@ -300,10 +300,10 @@ public class RewriteDataFilePlanner {
}
/**
- * Check if group has too much content
+ * Check if group content exceeds the maximum desired file size.
*/
private boolean hasTooMuchContent(RewriteDataGroup group) {
- return group.getTotalSize() > parameters.getMaxFileGroupSizeBytes();
+ return group.getTotalSize() > parameters.getMaxFileSizeBytes();
}
/**
diff --git
a/fe/fe-connector/fe-connector-iceberg/src/test/java/org/apache/doris/connector/iceberg/IcebergProcedureOpsTest.java
b/fe/fe-connector/fe-connector-iceberg/src/test/java/org/apache/doris/connector/iceberg/IcebergProcedureOpsTest.java
index bb887ec7bf2..7c799b0a417 100644
---
a/fe/fe-connector/fe-connector-iceberg/src/test/java/org/apache/doris/connector/iceberg/IcebergProcedureOpsTest.java
+++
b/fe/fe-connector/fe-connector-iceberg/src/test/java/org/apache/doris/connector/iceberg/IcebergProcedureOpsTest.java
@@ -189,6 +189,34 @@ public class IcebergProcedureOpsTest {
Assertions.assertEquals(1, ops.tableCleanupCount, "rewrite planning
releases its operation-owned table");
}
+ @Test
+ public void planRewriteKeepsOneOversizedFileBelowGroupLimit() {
+ InMemoryCatalog catalog = new InMemoryCatalog();
+ catalog.initialize("test", Collections.emptyMap());
+ catalog.createNamespace(Namespace.of("db1"));
+ Schema schema = new Schema(Types.NestedField.required(1, "id",
Types.IntegerType.get()));
+ catalog.createTable(TableIdentifier.of("db1", "t"), schema,
PartitionSpec.unpartitioned());
+ append(catalog, "oversized", 100L);
+ RecordingIcebergCatalogOps ops = new RecordingIcebergCatalogOps();
+ ops.table = catalog.loadTable(TableIdentifier.of("db1", "t"));
+ RecordingConnectorContext ctx = new RecordingConnectorContext();
+ IcebergProcedureOps procOps = new
IcebergProcedureOps(Collections.emptyMap(), ops, ctx);
+
+ List<ConnectorRewriteGroup> groups = procOps.planRewrite(SESSION, new
IcebergTableHandle("db1", "t"),
+ "rewrite_data_files",
ImmutableMap.of("target-file-size-bytes", "512",
+ "min-file-size-bytes", "384", "max-file-size-bytes",
"900",
+ "max-file-group-size-bytes", "100000"), null,
Collections.emptyList());
+
+ Assertions.assertEquals(1, groups.size());
+ ConnectorRewriteGroup group = groups.get(0);
+
Assertions.assertEquals(ImmutableSet.of("s3://b/db1/oversized.parquet"),
group.getDataFilePaths());
+ Assertions.assertEquals(1, group.getDataFileCount());
+ Assertions.assertEquals(1024L, group.getTotalSizeBytes());
+ Assertions.assertEquals(0, group.getDeleteFileCount());
+ Assertions.assertEquals(1, ctx.authCount);
+ Assertions.assertEquals(1, ops.tableCleanupCount);
+ }
+
@Test
public void planRewriteEmptyTableReturnsNoGroups() {
InMemoryCatalog catalog = new InMemoryCatalog();
diff --git
a/fe/fe-connector/fe-connector-iceberg/src/test/java/org/apache/doris/connector/iceberg/rewrite/RewriteDataFilePlannerTest.java
b/fe/fe-connector/fe-connector-iceberg/src/test/java/org/apache/doris/connector/iceberg/rewrite/RewriteDataFilePlannerTest.java
index e2b8005079f..41f12027c95 100644
---
a/fe/fe-connector/fe-connector-iceberg/src/test/java/org/apache/doris/connector/iceberg/rewrite/RewriteDataFilePlannerTest.java
+++
b/fe/fe-connector/fe-connector-iceberg/src/test/java/org/apache/doris/connector/iceberg/rewrite/RewriteDataFilePlannerTest.java
@@ -17,6 +17,7 @@
package org.apache.doris.connector.iceberg.rewrite;
+import org.apache.doris.connector.iceberg.action.IcebergRewriteDataFilesAction;
import org.apache.doris.connector.spi.ConnectorType;
import org.apache.doris.connector.spi.DorisConnectorException;
import org.apache.doris.connector.spi.pushdown.ConnectorAnd;
@@ -48,6 +49,8 @@ import org.apache.iceberg.types.Types;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.CsvSource;
import java.time.ZoneOffset;
import java.util.Arrays;
@@ -55,6 +58,7 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -171,6 +175,15 @@ public class RewriteDataFilePlannerTest {
return params(0L, Long.MAX_VALUE, 5, true, maxGroupSize, where);
}
+ private static RewriteDataFilePlanner.Parameters sizeBasedParams(long
maxGroupSize, int minInputFiles) {
+ IcebergRewriteDataFilesAction action = new
IcebergRewriteDataFilesAction(Map.of(
+ "target-file-size-bytes", "512", "min-file-size-bytes", "384",
"max-file-size-bytes", "900",
+ "max-file-group-size-bytes", Long.toString(maxGroupSize),
+ "min-input-files", Integer.toString(minInputFiles)),
Collections.emptyList(), null);
+ action.validate();
+ return action.buildRewriteParameters();
+ }
+
private static List<RewriteDataGroup> plan(Table table,
RewriteDataFilePlanner.Parameters p) {
return new RewriteDataFilePlanner(p,
ZoneOffset.UTC).planAndOrganizeTasks(table);
}
@@ -501,7 +514,7 @@ public class RewriteDataFilePlannerTest {
append(t, unpartFile("a", 100), unpartFile("b", 100));
// Files selected (100 < min 200). Group: count 2, size 200.
minInputFiles 100 disables hasEnoughInputFiles;
- // hasEnoughContent fires alone (count > 1 && size 200 > target 150);
size 200 <= group cap so hasTooMuchContent off.
+ // hasEnoughContent fires alone (count > 1 && size 200 > target 150);
size 200 <= max file size.
List<RewriteDataGroup> groups = new RewriteDataFilePlanner(
new RewriteDataFilePlanner.Parameters(150L, 200L, 1000L, 100,
false, 1_000_000L,
Integer.MAX_VALUE, 0.3, 2L, null),
ZoneOffset.UTC).planAndOrganizeTasks(t);
@@ -510,19 +523,71 @@ public class RewriteDataFilePlannerTest {
Assertions.assertEquals(2, totalFiles(groups));
}
- @Test
- public void groupFilterKeepsViaTooMuchContent() {
+ @ParameterizedTest
+ @CsvSource({"100000, 5", "200000, 5", "100000, 1", "200000, 1", "1024, 5",
"900, 5"})
+ public void groupFilterKeepsOneOversizedFile(long maxGroupSize, int
minInputFiles) {
Table t = createUnpartitioned("t14");
- append(t, unpartFile("a", 2000));
+ DataFile file = unpartFile("oversized.parquet", 1024);
+ append(t, file);
+
+ // A single oversized file must survive both filters, independently of
the group cap or file-count limit.
+ List<RewriteDataGroup> groups = plan(t, sizeBasedParams(maxGroupSize,
minInputFiles));
+
+ Assertions.assertEquals(1, groups.size());
+ Assertions.assertEquals(1, totalFiles(groups));
+ Assertions.assertEquals(1024L, groups.get(0).getTotalSize());
+ Assertions.assertEquals(file.path().toString(),
groups.get(0).getDataFiles().get(0).path().toString());
+ }
+
+ @ParameterizedTest
+ @CsvSource({"1, 100000", "383, 100000", "384, 100000", "512, 100000",
"900, 100000", "383, 100"})
+ public void groupFilterSkipsOneFileAtOrBelowMaxSize(long fileSize, long
maxGroupSize) {
+ Table t = createUnpartitioned("single_file");
+ append(t, unpartFile("a", fileSize));
+
+ Assertions.assertTrue(plan(t, sizeBasedParams(maxGroupSize,
5)).isEmpty());
+ }
+
+ @Test
+ public void groupFilterKeepsOversizedFileWithDefaultOptions() {
+ Table t = createUnpartitioned("default_options");
+ append(t, unpartFile("a", 1024L * 1024 * 1024));
+ IcebergRewriteDataFilesAction action = new
IcebergRewriteDataFilesAction(
+ Collections.emptyMap(), Collections.emptyList(), null);
+ action.validate();
- // One oversized file: selected (2000 > max 1000), packed alone into a
2000-byte group that exceeds the
- // 1500 group cap -> hasTooMuchContent fires (the only true OR-arm;
count 1 disables the count/content arms).
- List<RewriteDataGroup> groups = plan(t, params(0L, 1000L, 100, false,
1500L, null));
+ List<RewriteDataGroup> groups = plan(t,
action.buildRewriteParameters());
Assertions.assertEquals(1, groups.size());
Assertions.assertEquals(1, totalFiles(groups));
}
+ @Test
+ public void groupFilterKeepsSmallFilesAtMinInputCount() {
+ Table t = createUnpartitioned("small_files");
+ append(t, unpartFile("a", 100), unpartFile("b", 100), unpartFile("c",
100),
+ unpartFile("d", 100), unpartFile("e", 100));
+
+ List<RewriteDataGroup> groups = plan(t, sizeBasedParams(100000L, 5));
+
+ Assertions.assertEquals(1, groups.size());
+ Assertions.assertEquals(5, totalFiles(groups));
+ Assertions.assertEquals(500L, groups.get(0).getTotalSize());
+ }
+
+ @Test
+ public void oversizedFilesStillUseGroupSizeForPacking() {
+ Table t = createUnpartitioned("oversized_groups");
+ append(t, unpartFile("a", 1024), unpartFile("b", 1024),
unpartFile("c", 1024));
+
+ List<RewriteDataGroup> groups = plan(t, sizeBasedParams(2500L, 5));
+
+ Assertions.assertEquals(2, groups.size());
+ Assertions.assertEquals(3, totalFiles(groups));
+ Assertions.assertEquals(new HashSet<>(Arrays.asList(1024L, 2048L)),
+ new HashSet<>(Arrays.asList(groups.get(0).getTotalSize(),
groups.get(1).getTotalSize())));
+ }
+
@Test
public void fileAtSizeBoundariesIsInRange() {
Table t = createUnpartitioned("t15");
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]