Skip to content

Commit fa43afc

Browse files
authored
[fix](hudi) return empty if there is no commit implemented (#37702)
## Proposed changes Return empty set when there is no commit implemented, instead of throwing error: ``` HoodieException("No instants to incrementally pull") ```
1 parent 83a734e commit fa43afc

File tree

2 files changed

+80
-1
lines changed

2 files changed

+80
-1
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
package org.apache.doris.datasource.hudi.source;
19+
20+
import org.apache.doris.spi.Split;
21+
22+
import org.apache.hudi.common.model.FileSlice;
23+
import org.apache.hudi.exception.HoodieException;
24+
25+
import java.util.Collections;
26+
import java.util.List;
27+
import java.util.Map;
28+
29+
public class EmptyIncrementalRelation implements IncrementalRelation {
30+
private static final String EMPTY_TS = "000";
31+
32+
private final Map<String, String> optParams;
33+
34+
public EmptyIncrementalRelation(Map<String, String> optParams) {
35+
this.optParams = optParams;
36+
}
37+
38+
@Override
39+
public List<FileSlice> collectFileSlices() throws HoodieException {
40+
return Collections.emptyList();
41+
}
42+
43+
@Override
44+
public List<Split> collectSplits() throws HoodieException {
45+
return Collections.emptyList();
46+
}
47+
48+
@Override
49+
public Map<String, String> getHoodieParams() {
50+
optParams.put("hoodie.datasource.read.incr.operation", "true");
51+
optParams.put("hoodie.datasource.read.begin.instanttime", EMPTY_TS);
52+
optParams.put("hoodie.datasource.read.end.instanttime", EMPTY_TS);
53+
optParams.put("hoodie.datasource.read.incr.includeStartTime", "true");
54+
return optParams;
55+
}
56+
57+
@Override
58+
public boolean fallbackFullTableScan() {
59+
return false;
60+
}
61+
62+
@Override
63+
public boolean isIncludeStartTime() {
64+
return true;
65+
}
66+
67+
@Override
68+
public String getStartTs() {
69+
return EMPTY_TS;
70+
}
71+
72+
@Override
73+
public String getEndTs() {
74+
return EMPTY_TS;
75+
}
76+
}

fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalHudiScan.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.apache.doris.datasource.hive.HMSExternalTable;
2424
import org.apache.doris.datasource.hive.HiveMetaStoreClientHelper;
2525
import org.apache.doris.datasource.hudi.source.COWIncrementalRelation;
26+
import org.apache.doris.datasource.hudi.source.EmptyIncrementalRelation;
2627
import org.apache.doris.datasource.hudi.source.IncrementalRelation;
2728
import org.apache.doris.datasource.hudi.source.MORIncrementalRelation;
2829
import org.apache.doris.nereids.exceptions.AnalysisException;
@@ -206,7 +207,9 @@ public LogicalHudiScan withScanParams(HMSExternalTable table, TableScanParams sc
206207
LOG.warn("Execute incremental read on RO table: {}", table.getFullQualifiers());
207208
}
208209
}
209-
if (isCowOrRoTable) {
210+
if (hudiClient.getCommitsTimeline().filterCompletedInstants().countInstants() == 0) {
211+
newIncrementalRelation = Optional.of(new EmptyIncrementalRelation(optParams));
212+
} else if (isCowOrRoTable) {
210213
newIncrementalRelation = Optional.of(new COWIncrementalRelation(
211214
optParams, HiveMetaStoreClientHelper.getConfiguration(table), hudiClient));
212215
} else {

0 commit comments

Comments
 (0)