This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-4.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-4.1 by this push:
new c968b14c88a branch-4.1: [improvement](fe) Skip zero-length files in
FileSplitter to avoid sending empty splits to BE #62482 (#62662)
c968b14c88a is described below
commit c968b14c88a7b5ed990e1c65477e423788f9d6e8
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Wed Apr 22 15:28:36 2026 +0800
branch-4.1: [improvement](fe) Skip zero-length files in FileSplitter to
avoid sending empty splits to BE #62482 (#62662)
Cherry-picked from #62482
Co-authored-by: Qi Chen <[email protected]>
---
.../org/apache/doris/datasource/FileSplitter.java | 4 ++++
.../apache/doris/datasource/FileSplitterTest.java | 24 ++++++++++++++++++++++
2 files changed, 28 insertions(+)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/datasource/FileSplitter.java
b/fe/fe-core/src/main/java/org/apache/doris/datasource/FileSplitter.java
index 5fe84441971..b4e417b4f91 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/FileSplitter.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/FileSplitter.java
@@ -101,6 +101,10 @@ public class FileSplitter {
List<String> partitionValues,
SplitCreator splitCreator)
throws IOException {
+ if (length <= 0) {
+ // Zero-length files contain no data; skip to avoid sending empty
splits to BE.
+ return Lists.newArrayList();
+ }
// Pass splitCreator.create() to set target file split size to
calculate split weight.
long targetFileSplitSize = specifiedFileSplitSize > 0 ?
specifiedFileSplitSize : maxSplitSize;
if (blockLocations == null) {
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/datasource/FileSplitterTest.java
b/fe/fe-core/src/test/java/org/apache/doris/datasource/FileSplitterTest.java
index a455923da4d..5a391351038 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/datasource/FileSplitterTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/datasource/FileSplitterTest.java
@@ -195,6 +195,30 @@ public class FileSplitterTest {
Assert.assertEquals(1, splits.size());
}
+ @Test
+ public void testZeroLengthFileProducesNoSplits() throws Exception {
+ LocationPath loc =
LocationPath.of("hdfs://example.com/path/emptyfile");
+ BlockLocation[] locations = new BlockLocation[]{new
BlockLocation(null, new String[]{"h1"}, 0L, 0L)};
+ FileSplitter fileSplitter = new FileSplitter(32 * MB, 64 * MB,
DEFAULT_INITIAL_SPLITS);
+ // Non-splittable zero-length file
+ List<Split> splits = fileSplitter.splitFile(
+ loc, 0L, locations, 0L, 0L, false,
+ Collections.emptyList(), FileSplit.FileSplitCreator.DEFAULT);
+ Assert.assertTrue("Zero-length file should produce no splits",
splits.isEmpty());
+ // Splittable zero-length file
+ splits = fileSplitter.splitFile(
+ loc, 0L, locations, 0L, 0L, true,
+ Collections.emptyList(), FileSplit.FileSplitCreator.DEFAULT);
+ Assert.assertTrue("Zero-length splittable file should produce no
splits", splits.isEmpty());
+ // Null block locations with zero-length file
+ splits = fileSplitter.splitFile(
+ loc, 0L, null, 0L, 0L, true,
+ Collections.emptyList(), FileSplit.FileSplitCreator.DEFAULT);
+ Assert.assertTrue("Zero-length file with null locations should produce
no splits", splits.isEmpty());
+ // Counter should not be decremented for skipped zero-length files
+ Assert.assertEquals(DEFAULT_INITIAL_SPLITS,
fileSplitter.getRemainingInitialSplitNum());
+ }
+
@Test
public void testSmallFileNoSplit() throws Exception {
LocationPath loc = LocationPath.of("hdfs://example.com/path/small");
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]