Skip to content

Commit a7ca9e3

Browse files
seawindeseawinde
authored andcommitted
[feature](fe) Support MTMV refresh fallback strategy (apache#14)
* [feature](fe) Support MTMV refresh fallback strategy Issue Number: close #xxx Related PR: #xxx Problem Summary: Add MTMV refresh method fallback semantics for AUTO, INCREMENTAL, PARTITIONS and COMPLETE refresh execution. Persist fallback policy, route scheduled and commit jobs through MV default strategy, and make IVM delta execution failures hard failures while allowing precheck/analyze fallback. Support MTMV refresh fallback strategy syntax and execution semantics. - Test: Unit Test - ./run-fe-ut.sh --run org.apache.doris.mtmv.ivm.IvmRefreshManagerTest,org.apache.doris.mtmv.MTMVTaskTest,org.apache.doris.mtmv.MTMVJobManagerTest,org.apache.doris.job.extensions.mtmv.MTMVTaskContextCompatTest,org.apache.doris.nereids.trees.plans.commands.RefreshMTMVCommandTest,org.apache.doris.nereids.trees.plans.commands.info.RefreshMTMVInfoAnalyzeTest,org.apache.doris.nereids.trees.plans.commands.ExplainRefreshIvmCommandTest - ./run-fe-ut.sh --run org.apache.doris.nereids.trees.plans.CreateMTMVCommandTest,org.apache.doris.mtmv.AlterMTMVTest - Behavior changed: Yes. MTMV refresh strategy now separates refresh method from fallback policy and uses method-specific fallback chains. - Does this need documentation: Yes * [doc](fe) Clarify MTMV refresh fallback code paths Issue Number: N/A Related PR: N/A Problem Summary: Add explanatory comments for the MTMV refresh fallback implementation, covering persisted fallback metadata, task default-policy resolution, fallback attempt boundaries, and IVM execution hard-failure recovery semantics. None - Test: Unit Test - git diff --check - ./run-fe-ut.sh --run org.apache.doris.job.extensions.mtmv.MTMVTaskContextCompatTest,org.apache.doris.nereids.trees.plans.commands.info.RefreshMTMVInfoAnalyzeTest,org.apache.doris.nereids.trees.plans.CreateMTMVCommandTest,org.apache.doris.mtmv.AlterMTMVTest,org.apache.doris.mtmv.ivm.IvmRefreshManagerTest - Behavior changed: No - Does this need documentation: No * [fix](fe) Address MTMV refresh fallback review comments Issue Number: close #xxx Related PR: #xxx Problem Summary: Address review comments for MTMV refresh fallback. The fallback loop now routes IVM direct-to-complete recovery through the normal COMPLETE attempt by marking partition refresh disabled, partition refresh planning is wrapped inside the partition refresh helper, unused tryIvmFastPath was removed, non-IVM IVM attempts now fail directly, MTMVTaskContext uses short serialized field names while keeping old JSON aliases, and TODOs document additional IVM recovery classifications. None - Test: Unit Test - git diff --check - Attempted ./run-fe-ut.sh --run org.apache.doris.mtmv.MTMVTaskTest,org.apache.doris.job.extensions.mtmv.MTMVTaskContextCompatTest, but it failed during FE Core testCompile with missing generated/project classes such as Patterns, CascadesContext, LogicalPlan, and HMSExternalTable before running the selected tests. - Behavior changed: No - Does this need documentation: No * [fix](fe) Preserve IVM execution failure reasons Issue Number: None Related PR: apache#14 Problem Summary: IVM execution-time guard failures for min/max boundary hits and non-deterministic row ids were collapsed into INCREMENTAL_EXECUTION_FAILED, losing the reason needed for diagnosis and follow-up recovery strategy. MTMVTaskContext also exposed multiple public constructors for each new policy field. This change classifies known runtime guard messages back to stable IvmFailureReason values while keeping execution failures as hard failures, and narrows MTMVTaskContext explicit policy construction to static factories. None - Test: Manual test - Ran git diff --check. - Tried ./run-fe-ut.sh --run org.apache.doris.mtmv.ivm.IvmRefreshManagerTest,org.apache.doris.job.extensions.mtmv.MTMVTaskContextCompatTest,org.apache.doris.mtmv.MTMVTaskTest; blocked in fe-core testCompile by missing existing generated/main classes such as CascadesContext, LogicalPlan and GeneratedMemoPatterns. - Tried cd fe && mvn -pl fe-core -am -DskipTests -Dcheckstyle.skip=true -Dmaven.build.cache.enabled=false compile; blocked in fe-core generate-patterns because PatternDescribableProcessor was not found. - Behavior changed: No - Does this need documentation: No * [fix](fe) Fix MTMV incremental fallback attempts Issue Number: close #xxx Related PR: apache#14 Problem Summary: Non-IVM materialized views were allowed to accept manual INCREMENTAL FALLBACK requests, but the task attempt builder still scheduled an IVM attempt first. Since the IVM attempt now fails fast for non-IVM MVs, that path failed before reaching the intended PARTITIONS/COMPLETE fallback chain. This change skips the IVM attempt for non-IVM INCREMENTAL FALLBACK while preserving strict INCREMENTAL fail-fast behavior, and fixes FE checkstyle issues reported by CI. None - Test: Unit Test - git diff --check - Behavior changed: No - Does this need documentation: No * [fix](fe) Remove unused IVM test import Issue Number: close #xxx Related PR: apache#14 Problem Summary: FE CheckStyle failed on an unused import in IvmNormalizeMtmvTest when validating the PR merge ref. Remove the unused import so the full FE checkstyle job can proceed. None - Test: Unit Test - Ran targeted FE CheckStyle for IvmNormalizeMtmvTest. - Behavior changed: No - Does this need documentation: No * [fix](fe) Validate MTMV refresh policy compatibility Issue Number: None Related PR: apache#14 Problem Summary: Manual MTMV refresh analysis still relied on IVM capability only, so refresh-mode compatibility did not consistently match the MV refresh policy. INCREMENTAL fallback also skipped the IVM attempt for non-IVM MVs, which bypassed the intended fallback path. This change validates the requested refresh mode against the MV refresh method and partition mode, keeps the IVM attempt in the incremental fallback sequence, and extends unit coverage for COMPLETE, PARTITIONS, INCREMENTAL, and AUTO policy combinations. Refresh MATERIALIZED VIEW now validates the requested refresh mode against the materialized view refresh policy. - Test: Unit Test - git diff --check - ./run-fe-ut.sh --run org.apache.doris.mtmv.MTMVTaskTest,org.apache.doris.nereids.trees.plans.commands.info.RefreshMTMVInfoAnalyzeTest attempted, but failed before tests because fe-core compile could not resolve existing generated parser/proto classes, such as DorisParser.RefreshPolicyContext and Cloud.CreateMetaSyncPointRequest. - Behavior changed: Yes (manual MTMV refresh mode validation now follows the MV refresh policy, and incremental fallback keeps the IVM attempt before falling back) - Does this need documentation: No --------- Co-authored-by: seawinde <[email protected]>
1 parent 1e626b1 commit a7ca9e3

25 files changed

Lines changed: 1042 additions & 236 deletions

‎fe/fe-core/src/main/java/org/apache/doris/job/extensions/mtmv/MTMVJob.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ protected void checkJobParamsInternal() {
128128
public List<MTMVTask> createTasks(TaskType taskType, MTMVTaskContext taskContext) {
129129
LOG.info("begin create mtmv task, jobId: {}, taskContext: {}", super.getJobId(), taskContext);
130130
if (taskContext == null) {
131-
taskContext = new MTMVTaskContext(MTMVTaskTriggerMode.SYSTEM);
131+
taskContext = MTMVTaskContext.forMvDefault(MTMVTaskTriggerMode.SYSTEM);
132132
}
133133
MTMVTask task = new MTMVTask(dbId, mtmvId, taskContext);
134134
task.setTaskType(taskType);

‎fe/fe-core/src/main/java/org/apache/doris/job/extensions/mtmv/MTMVTask.java‎

Lines changed: 301 additions & 49 deletions
Large diffs are not rendered by default.

‎fe/fe-core/src/main/java/org/apache/doris/job/extensions/mtmv/MTMVTaskContext.java‎

Lines changed: 58 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -41,34 +41,32 @@ public class MTMVTaskContext {
4141
@SerializedName(value = "refreshMode")
4242
private RefreshMode refreshMode;
4343

44+
// Nullable for compatibility and partial policy sources:
45+
// null means the task did not persist an explicit fallback choice and should
46+
// use the default of its resolved refresh mode.
47+
@SerializedName(value = "af", alternate = "allowFallback")
48+
private Boolean allowFallback;
49+
50+
// True for scheduled/on-commit/system tasks whose refresh method must be
51+
// resolved from the MV's persisted refreshInfo at execution time. This is
52+
// separate from refreshMode == null because old task JSON also lacks
53+
// refreshMode and must still fall back to the legacy isComplete field.
54+
@SerializedName(value = "md", alternate = "useMvDefaultRefreshPolicy")
55+
private boolean useMvDefaultRefreshPolicy;
56+
4457
public MTMVTaskContext(MTMVTaskTriggerMode triggerMode) {
4558
this.triggerMode = triggerMode;
4659
this.refreshMode = RefreshMode.AUTO;
60+
this.allowFallback = true;
4761
}
4862

49-
public MTMVTaskContext(MTMVTaskTriggerMode triggerMode, List<String> partitions, RefreshMode refreshMode) {
50-
this(triggerMode, partitions, refreshMode, null);
51-
}
52-
53-
public MTMVTaskContext(MTMVTaskTriggerMode triggerMode, List<String> partitions, RefreshMode refreshMode,
54-
String computeGroup) {
63+
private MTMVTaskContext(MTMVTaskTriggerMode triggerMode, List<String> partitions, RefreshMode refreshMode,
64+
boolean allowFallback, String computeGroup) {
5565
this.triggerMode = triggerMode;
5666
this.partitions = partitions;
5767
this.refreshMode = refreshMode;
5868
this.isComplete = refreshMode == RefreshMode.COMPLETE;
59-
this.computeGroup = computeGroup;
60-
}
61-
62-
public MTMVTaskContext(MTMVTaskTriggerMode triggerMode, List<String> partitions, boolean isComplete) {
63-
this(triggerMode, partitions, isComplete, null);
64-
}
65-
66-
public MTMVTaskContext(MTMVTaskTriggerMode triggerMode, List<String> partitions, boolean isComplete,
67-
String computeGroup) {
68-
this.triggerMode = triggerMode;
69-
this.partitions = partitions;
70-
this.isComplete = isComplete;
71-
this.refreshMode = isComplete ? RefreshMode.COMPLETE : RefreshMode.AUTO;
69+
this.allowFallback = allowFallback;
7270
this.computeGroup = computeGroup;
7371
}
7472

@@ -102,13 +100,54 @@ public RefreshMode getRefreshMode() {
102100
return isComplete ? RefreshMode.COMPLETE : RefreshMode.AUTO;
103101
}
104102

103+
public boolean allowFallback() {
104+
if (allowFallback != null) {
105+
return allowFallback;
106+
}
107+
// Old serialized tasks did not have allowFallback. Reconstruct the
108+
// intended behavior from the resolved refresh mode: only AUTO defaults
109+
// to fallback.
110+
return defaultAllowFallback(getRefreshMode());
111+
}
112+
113+
public boolean useMvDefaultRefreshPolicy() {
114+
return useMvDefaultRefreshPolicy;
115+
}
116+
117+
public static MTMVTaskContext forMvDefault(MTMVTaskTriggerMode triggerMode) {
118+
MTMVTaskContext taskContext = new MTMVTaskContext(triggerMode);
119+
// Do not persist AUTO here. The actual method may be PARTITIONS,
120+
// INCREMENTAL, or COMPLETE after CREATE/ALTER, so the task must read
121+
// the MV default policy when it runs.
122+
taskContext.refreshMode = null;
123+
taskContext.allowFallback = null;
124+
taskContext.useMvDefaultRefreshPolicy = true;
125+
return taskContext;
126+
}
127+
128+
public static MTMVTaskContext of(MTMVTaskTriggerMode triggerMode, List<String> partitions,
129+
RefreshMode refreshMode) {
130+
return new MTMVTaskContext(triggerMode, partitions, refreshMode, defaultAllowFallback(refreshMode), null);
131+
}
132+
133+
public static MTMVTaskContext of(MTMVTaskTriggerMode triggerMode, List<String> partitions,
134+
RefreshMode refreshMode, boolean allowFallback, String computeGroup) {
135+
return new MTMVTaskContext(triggerMode, partitions, refreshMode, allowFallback, computeGroup);
136+
}
137+
138+
private static boolean defaultAllowFallback(RefreshMode refreshMode) {
139+
return refreshMode == RefreshMode.AUTO;
140+
}
141+
105142
@Override
106143
public String toString() {
107144
return "MTMVTaskContext{"
108145
+ "triggerMode=" + triggerMode
109146
+ ", partitions=" + partitions
110147
+ ", computeGroup=" + computeGroup
111148
+ ", refreshMode=" + getRefreshMode()
149+
+ ", allowFallback=" + allowFallback()
150+
+ ", useMvDefaultRefreshPolicy=" + useMvDefaultRefreshPolicy
112151
+ '}';
113152
}
114153
}

‎fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVJobManager.java‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
import org.apache.doris.nereids.trees.plans.commands.info.ResumeMTMVInfo;
4848
import org.apache.doris.qe.ConnectContext;
4949

50-
import com.google.common.collect.Lists;
5150
import org.apache.commons.lang3.StringUtils;
5251
import org.apache.logging.log4j.LogManager;
5352
import org.apache.logging.log4j.Logger;
@@ -68,7 +67,7 @@ public void postCreateMTMV(MTMV mtmv) {
6867
if (!mtmv.getRefreshInfo().getBuildMode().equals(BuildMode.IMMEDIATE)) {
6968
return;
7069
}
71-
MTMVTaskContext mtmvTaskContext = new MTMVTaskContext(MTMVTaskTriggerMode.SYSTEM, null,
70+
MTMVTaskContext mtmvTaskContext = MTMVTaskContext.of(MTMVTaskTriggerMode.SYSTEM, null,
7271
RefreshMode.COMPLETE);
7372
try {
7473
Env.getCurrentEnv().getJobManager().triggerJob(mtmv.getId(), mtmvTaskContext);
@@ -159,8 +158,8 @@ public void alterJob(MTMV mtmv, boolean isReplay) {
159158
@Override
160159
public void refreshMTMV(RefreshMTMVInfo info) throws DdlException, MetaNotFoundException, JobException {
161160
MTMVJob job = getJobByTableNameInfo(info.getMvName());
162-
MTMVTaskContext mtmvTaskContext = new MTMVTaskContext(MTMVTaskTriggerMode.MANUAL, info.getPartitions(),
163-
info.getRefreshMode(), getCurrentComputeGroup());
161+
MTMVTaskContext mtmvTaskContext = MTMVTaskContext.of(MTMVTaskTriggerMode.MANUAL, info.getPartitions(),
162+
info.getRefreshMode(), info.allowFallback(), getCurrentComputeGroup());
164163
Env.getCurrentEnv().getJobManager().triggerJob(job.getJobId(), mtmvTaskContext);
165164
}
166165

@@ -222,8 +221,7 @@ public void onCommit(MTMV mtmv) throws DdlException, JobException {
222221
}
223222
return;
224223
}
225-
MTMVTaskContext mtmvTaskContext = new MTMVTaskContext(MTMVTaskTriggerMode.COMMIT, Lists.newArrayList(),
226-
RefreshMode.AUTO);
224+
MTMVTaskContext mtmvTaskContext = MTMVTaskContext.forMvDefault(MTMVTaskTriggerMode.COMMIT);
227225
Env.getCurrentEnv().getJobManager().triggerJob(job.getJobId(), mtmvTaskContext);
228226
}
229227

‎fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVRefreshEnum.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ public class MTMVRefreshEnum {
2828
public enum RefreshMethod {
2929
COMPLETE, //complete
3030
AUTO, // existing auto refresh behavior
31-
INCREMENTAL // opt in nereids ivm rewrite flow
31+
INCREMENTAL, // opt in nereids ivm rewrite flow
32+
PARTITIONS // partition-based refresh
3233
}
3334

3435
/**

‎fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVRefreshInfo.java‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import org.apache.doris.mtmv.MTMVRefreshEnum.BuildMode;
2121
import org.apache.doris.mtmv.MTMVRefreshEnum.RefreshMethod;
22+
import org.apache.doris.nereids.exceptions.AnalysisException;
2223

2324
import com.google.gson.annotations.SerializedName;
2425

@@ -32,6 +33,11 @@ public class MTMVRefreshInfo {
3233
private BuildMode buildMode;
3334
@SerializedName("rm")
3435
private RefreshMethod refreshMethod;
36+
// Nullable because ALTER may update only the trigger or method. A null
37+
// value means "not specified in this update" or "old metadata"; the effective
38+
// value is derived from the refresh method.
39+
@SerializedName("af")
40+
private Boolean allowFallback;
3541
@SerializedName("rti")
3642
private MTMVRefreshTriggerInfo refreshTriggerInfo;
3743

@@ -41,12 +47,25 @@ public MTMVRefreshInfo() {
4147
public MTMVRefreshInfo(BuildMode buildMode,
4248
RefreshMethod refreshMethod,
4349
MTMVRefreshTriggerInfo refreshTriggerInfo) {
50+
this(buildMode, refreshMethod, defaultAllowFallback(refreshMethod), refreshTriggerInfo);
51+
}
52+
53+
public MTMVRefreshInfo(BuildMode buildMode,
54+
RefreshMethod refreshMethod,
55+
boolean allowFallback,
56+
MTMVRefreshTriggerInfo refreshTriggerInfo) {
4457
this.buildMode = Objects.requireNonNull(buildMode, "require buildMode object");
4558
this.refreshMethod = Objects.requireNonNull(refreshMethod, "require refreshMethod object");
59+
this.allowFallback = allowFallback;
4660
this.refreshTriggerInfo = Objects.requireNonNull(refreshTriggerInfo, "require refreshTriggerInfo object");
4761
}
4862

4963
public void validate() {
64+
// COMPLETE is already the last refresh attempt, so FALLBACK would be
65+
// meaningless and can hide invalid SQL/metadata.
66+
if (refreshMethod == RefreshMethod.COMPLETE && allowFallback()) {
67+
throw new AnalysisException("COMPLETE refresh does not support FALLBACK");
68+
}
5069
if (refreshTriggerInfo != null) {
5170
refreshTriggerInfo.validate();
5271
}
@@ -64,6 +83,24 @@ public MTMVRefreshTriggerInfo getRefreshTriggerInfo() {
6483
return refreshTriggerInfo;
6584
}
6685

86+
public Boolean getAllowFallback() {
87+
return allowFallback;
88+
}
89+
90+
public boolean allowFallback() {
91+
if (allowFallback != null) {
92+
return allowFallback;
93+
}
94+
// Backward compatibility for metadata written before allowFallback was
95+
// persisted: AUTO kept its implicit fallback behavior; strict methods do
96+
// not gain fallback unless it is explicitly stored.
97+
return defaultAllowFallback(refreshMethod);
98+
}
99+
100+
public static boolean defaultAllowFallback(RefreshMethod refreshMethod) {
101+
return refreshMethod == RefreshMethod.AUTO;
102+
}
103+
67104
public void setBuildMode(BuildMode buildMode) {
68105
this.buildMode = buildMode;
69106
}
@@ -72,6 +109,10 @@ public void setRefreshMethod(RefreshMethod refreshMethod) {
72109
this.refreshMethod = refreshMethod;
73110
}
74111

112+
public void setAllowFallback(Boolean allowFallback) {
113+
this.allowFallback = allowFallback;
114+
}
115+
75116
public void setRefreshTriggerInfo(
76117
MTMVRefreshTriggerInfo refreshTriggerInfo) {
77118
this.refreshTriggerInfo = refreshTriggerInfo;
@@ -87,6 +128,13 @@ public MTMVRefreshInfo updateNotNull(MTMVRefreshInfo newRefreshInfo) {
87128
}
88129
if (newRefreshInfo.refreshMethod != null) {
89130
this.refreshMethod = newRefreshInfo.refreshMethod;
131+
// When ALTER changes the method but does not specify FALLBACK,
132+
// reset fallback to the new method default instead of carrying over
133+
// the old method's fallback setting.
134+
this.allowFallback = newRefreshInfo.allowFallback != null
135+
? newRefreshInfo.allowFallback : defaultAllowFallback(newRefreshInfo.refreshMethod);
136+
} else if (newRefreshInfo.allowFallback != null) {
137+
this.allowFallback = newRefreshInfo.allowFallback;
90138
}
91139
if (newRefreshInfo.refreshTriggerInfo != null) {
92140
this.refreshTriggerInfo = newRefreshInfo.refreshTriggerInfo;
@@ -101,6 +149,9 @@ public String toString() {
101149
builder.append(buildMode);
102150
builder.append(" REFRESH ");
103151
builder.append(refreshMethod);
152+
if (allowFallback() && refreshMethod != RefreshMethod.AUTO) {
153+
builder.append(" FALLBACK");
154+
}
104155
builder.append(" ");
105156
builder.append(refreshTriggerInfo);
106157
return builder.toString();

‎fe/fe-core/src/main/java/org/apache/doris/mtmv/ivm/IvmAggDeltaHandler.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
*
7575
* <p>Handles single-table aggregate MVs with count/sum/avg/min/max.
7676
* Min/max use an assert_true guard: if a deleted row matches the current extreme,
77-
* execution fails and IvmRefreshManager falls back to COMPLETE refresh.
77+
* execution fails with a reason that requires full refresh recovery.
7878
*
7979
* <h3>Overall flow</h3>
8080
* <ol>

‎fe/fe-core/src/main/java/org/apache/doris/mtmv/ivm/IvmDeltaRewriteHelper.java‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,6 @@
5757
class IvmDeltaRewriteHelper {
5858
static final IvmDeltaRewriteHelper INSTANCE = new IvmDeltaRewriteHelper();
5959

60-
private static final String NON_DET_ROW_ID_MSG_PREFIX =
61-
"IVM fallback: delete on non-deterministic row_id in ";
62-
6360
private IvmDeltaRewriteHelper() {
6461
}
6562

@@ -133,10 +130,10 @@ boolean needNonDetGuard(Plan snapshotSidePlan, IvmRefreshContext ctx) {
133130

134131
/**
135132
* Wraps the dml_factor slot with an assert_true guard that triggers a runtime exception
136-
* when dml_factor < 0, causing fallback to full refresh.
133+
* when dml_factor < 0 and preserves the fallback reason for recovery.
137134
*/
138135
IvmDeltaRewriteResult wrapDmlFactorWithNonDetGuard(IvmDeltaRewriteResult result, JoinType joinType) {
139-
String msg = NON_DET_ROW_ID_MSG_PREFIX + joinType;
136+
String msg = IvmFailureClassifier.NON_DETERMINISTIC_ROW_ID_MSG_PREFIX + " in " + joinType;
140137
Expression guardedExpr = new If(
141138
new AssertTrue(new GreaterThanEqual(result.dmlFactorSlot,
142139
new TinyIntLiteral((byte) 0)), new StringLiteral(msg)),
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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.mtmv.ivm;
19+
20+
import java.util.Objects;
21+
import java.util.Optional;
22+
23+
/**
24+
* Maps runtime guard failures back to stable IVM failure reasons.
25+
*/
26+
public final class IvmFailureClassifier {
27+
public static final String MIN_MAX_BOUNDARY_MSG_PREFIX = "IVM fallback: min/max boundary hit";
28+
public static final String NON_DETERMINISTIC_ROW_ID_MSG_PREFIX =
29+
"IVM fallback: delete on non-deterministic row_id";
30+
31+
private IvmFailureClassifier() {
32+
}
33+
34+
public static Optional<IvmFailureReason> classifyExecutionFailure(String detail) {
35+
Objects.requireNonNull(detail, "detail can not be null");
36+
if (detail.contains(MIN_MAX_BOUNDARY_MSG_PREFIX)) {
37+
return Optional.of(IvmFailureReason.MIN_MAX_BOUNDARY_HIT);
38+
}
39+
if (detail.contains(NON_DETERMINISTIC_ROW_ID_MSG_PREFIX)) {
40+
return Optional.of(IvmFailureReason.NON_DETERMINISTIC_ROW_ID);
41+
}
42+
return Optional.empty();
43+
}
44+
}

0 commit comments

Comments
 (0)