Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
1d3e4e7
[feat](ivm) Add mtmv increment refresh framework
yujun777 Mar 17, 2026
69807a8
[feature](mtmv) add nereids ivm rewrite gate and tests
yujun777 Mar 17, 2026
be3b9d1
[feature](ivm) add refresh manager entry point
yujun777 Mar 17, 2026
109d034
[ivm] make plan analysis an analysis artifact
yujun777 Mar 17, 2026
89c64e6
Add thin IVM stream metadata precheck
yujun777 Mar 17, 2026
c522254
[ivm] fix IVMRefreshResult null contract, add toString and fallback l…
yujun777 Mar 17, 2026
24d6884
[ivm] replace DeltaPlanBundle description string with LogicalPlan and…
yujun777 Mar 18, 2026
3c0c3c4
[ivm] replace ivmPlanAnalysis with ivmDeltaBundles in CascadesContext
yujun777 Mar 18, 2026
4d04f18
[ivm] replace plan analyzer/dispatcher with Nereids delta rules
yujun777 Mar 18, 2026
28239d3
[ivm] refactor IVM Nereids rules: normalize + delta rule skeletons
yujun777 Mar 18, 2026
5b927d9
[ivm] introduce IvmAnalyzeMode and split IVM session variables
yujun777 Mar 18, 2026
e7b1e62
[ivm] implement IvmNormalizeMtmvPlan row-id injection and IvmContext
yujun777 Mar 18, 2026
5b9ae65
[ivm] wire row-id column into CreateMTMVInfo and add UTs
yujun777 Mar 18, 2026
b8ab2f1
[ivm] make IVM MV UNIQUE_KEYS+MOW and add key-type UTs
yujun777 Mar 18, 2026
cb64519
Rename IVM delta bundle to command bundle
yujun777 Mar 18, 2026
fc3671a
[ivm] remove mv_ prefix from IVM row-id column name
yujun777 Mar 18, 2026
4726d67
[ivm] move delta calculation outside Nereids and add skeleton IvmDelt…
yujun777 Mar 18, 2026
3ec67e1
[ivm] implement scan & project-scan delta rewriting in IvmDeltaRewriter
yujun777 Mar 18, 2026
24c5472
[ivm] convert IVMDeltaExecutor and IVMCapabilityChecker from interfac…
yujun777 Mar 18, 2026
dfd381a
[ivm] integrate IVM refresh into MTMVTask run flow
yujun777 Mar 18, 2026
4ac9988
[ivm] extract MTMVPlanUtil.executeCommand() and add audit log to IVMD…
yujun777 Mar 19, 2026
009711d
fix ivm refresh insert table command fail
yujun777 Mar 19, 2026
67255d8
[improvement](fe) Centralize IVM hidden column names
yujun777 Mar 19, 2026
06b3e26
[fix](fe) Remove unused MTMV imports
yujun777 Mar 19, 2026
f0d4067
[fix](fe) Preserve IVM row id in incremental mtmv refresh
yujun777 Mar 22, 2026
ddad190
[fix](fe) Refresh root fragment output exprs
yujun777 Mar 22, 2026
d3513bb
[fix](fe) Disable DML MV rewrite during MTMV refresh
yujun777 Mar 22, 2026
3db57e0
[fix](fe) Normalize incremental MTMV sink outputs
yujun777 Mar 24, 2026
5c57dea
[fix](fe) Fix redundant guard and checkstyle in incremental MTMV sink…
yujun777 Mar 24, 2026
430072e
[refactor](fe) Rename IVM normalize MTMV rule
yujun777 Mar 26, 2026
90933ec
[test](fe) Update FE unit test expectations
yujun777 Mar 26, 2026
b70fa63
[fix](fe) Reuse aggregate output alias slot for expression group keys
yujun777 Mar 26, 2026
93a4453
[fix](fe) Check translated output slot refs
yujun777 Mar 26, 2026
e602beb
[fix](fe) Restore view alias rewrite guard for simpleColumnDefinitions
yujun777 Mar 26, 2026
3ba2de6
[fix](fe) Preserve deferred TopN projected outputs
yujun777 Mar 27, 2026
4c467c8
[fix](fe) Limit MTMV alias rewrite to incremental refresh
yujun777 Mar 27, 2026
a3b764e
[fix](fe) Create MTMV context before StatementContext in refresh
yujun777 Mar 27, 2026
7cd5af3
[feature](fe) Add IVM aggregate normalization support
yujun777 Mar 31, 2026
cf62945
[refactor](fe) Rename IVM-prefixed classes to Ivm in mtmv/ivm package
yujun777 Mar 31, 2026
b6f61ca
[refactor](fe) Extract MTMV test cases from CreateTableCommandTest in…
yujun777 Mar 31, 2026
16dca0c
[refactor](fe) Split testConvertToPartitionTableInfo into four separa…
yujun777 Mar 31, 2026
18d55a5
[improvement](fe) Propagate IvmNormalizeResult through delta rewrite …
yujun777 Apr 2, 2026
133a827
[refactor](fe) Extract IvmDeltaStrategy interface and AbstractDeltaSt…
yujun777 Apr 2, 2026
d820533
[test](fe) Add aggregate IMMV creation test cases in CreateMTMVComman…
yujun777 Apr 2, 2026
706956c
[feature](fe) Add IVM agg delta rewrite strategies
yujun777 Apr 7, 2026
2c1a461
[fix](fe) Reuse MOW hidden columns for IVM MTMV
yujun777 Apr 7, 2026
751cea0
[refactor](fe) Rename IVM fallback and delta bundle types
yujun777 Apr 8, 2026
5757c28
[fix](fe) Persist IVM identity in MTMV metadata
yujun777 Apr 8, 2026
7784910
[feature](fe) Support explicit REFRESH MATERIALIZED VIEW ... INCREMEN…
seawinde Apr 8, 2026
b96977a
[fix](ivm) Ivm validate columns fix when create incremental mv (#3)
seawinde Apr 9, 2026
b68c9c4
[refactor](fe) Rename MvNondeterministicFunctionCollector back to Non…
yujun777 Apr 10, 2026
8095c45
[fix](fe) Hide physical UNIQUE KEY and row-id columns in SHOW CREATE …
seawinde Apr 10, 2026
3e43b3a
[refactor](fe) Consolidate isIvmHiddenColumn into IvmUtil
yujun777 Apr 12, 2026
911e4f9
[fix](fe) Fix IVM row duplication by enforcing HASH distribution on r…
yujun777 Apr 12, 2026
f71b975
[test](fe,regression) Add IVM distribution override UTs and DUP_KEYS …
yujun777 Apr 12, 2026
482a107
[fix](fe) Fix three IVM INCREMENTAL refresh bugs (null detail, null d…
yujun777 Apr 12, 2026
f513de2
[test](regression) Add scalar aggregate IVM regression test
yujun777 Apr 12, 2026
91ca5e7
[feature](fe) Add MIN/MAX aggregate support for IVM incremental refresh
yujun777 Apr 12, 2026
4f18216
(fe) Fix stale Javadoc, remove dead code, and enhance IVM MIN/MAX reg…
yujun777 Apr 13, 2026
36f2373
[improvement](fe) IVM SHOW CREATE outputs DISTRIBUTED BY RANDOM inste…
yujun777 Apr 13, 2026
4e5ea74
[doc](fe) Add IVM AGENTS.md with testing guidelines and development n…
yujun777 Apr 13, 2026
d9e87c1
[fix](fe) Fix NPE in MTMV refresh when definition SQL contains SET_VA…
yujun777 Apr 13, 2026
764f961
[feature](ivm) Derive dml_factor from binlog_op column and fix assert…
yujun777 Apr 13, 2026
5e567d7
[refactor](fe) Extract common methods from IvmAggDeltaStrategy and do…
yujun777 Apr 13, 2026
3a445f1
[test](regression) add NULL value regression tests for IVM aggregation
yujun777 Apr 13, 2026
4dd8a82
[test](regression) Add IVM agg regression tests for group deletion, s…
yujun777 Apr 13, 2026
b09c199
[test](fe) Add IVM agg gap tests and fix AVG(DECIMAL) ClassCastException
yujun777 Apr 13, 2026
e5362e0
move regression case to mtmv_p0/ivm
yujun777 Apr 13, 2026
fe5f3ff
[fix](fe) Fix null group key row_id collision in IVM
yujun777 Apr 14, 2026
c7e110e
[improvement](fe) Support expression arguments in IVM aggregate funct…
yujun777 Apr 14, 2026
1740abc
[refactor](fe) Replace raw string keys with StateKey enum in IVM agg …
yujun777 Apr 14, 2026
8fe8571
[improvement](fe) Improve IVM MIN/MAX boundary failure diagnosis
yujun777 Apr 14, 2026
be55c8f
[feature](fe) Support bare GROUP BY without aggregate functions in IVM
yujun777 Apr 14, 2026
f817fc5
[test](regression) Add INCREMENTAL output assertions to IVM agg regre…
yujun777 Apr 14, 2026
11d07fd
[doc](fe) Merge IVM regression test binlog_op guide into FE IVM AGENT…
yujun777 Apr 14, 2026
5a5fc4f
[test](fe) Replace IVM FE unit tests with Mockito
yujun777 Apr 14, 2026
0fcd755
[fix](fe) Replace remaining JMockit usage with Mockito in IvmRefreshM…
yujun777 Apr 15, 2026
778baff
[refactor](fe) Remove redundant hidden IVM columns for COUNT/SUM/MIN/MAX
yujun777 Apr 15, 2026
a1ae6f5
[refactor](fe) Merge COUNT_STAR/COUNT_EXPR into COUNT, replace StateK…
yujun777 Apr 15, 2026
d17ab68
[fix](fe) Fix import issues after rebase onto upstream/master
yujun777 Apr 16, 2026
9091564
[improvement](fe) Clean up COUNT branch and use isCountStar() for rob…
yujun777 Apr 16, 2026
dec8d11
[improvement](fe) Add MIN/MAX guard bypass when non-null count drops …
yujun777 Apr 16, 2026
6ca037a
Ivm pick create alter validation (#6)
seawinde Apr 16, 2026
36e733a
[improvement](fe) Clean up IVM normalize and alter refresh error mess…
yujun777 Apr 17, 2026
97d4f78
[feature](ivm) Implement multi-bundle delta plan generation (Steps 1-5)
yujun777 Apr 17, 2026
bd1e692
[feature](fe) Add runningIvmRefresh flag with editlog persistence and…
yujun777 Apr 17, 2026
ff9c0be
[improvement](fe) Add IVM unit tests and fix TSO read failure handling
yujun777 Apr 18, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions fe/fe-catalog/src/main/java/org/apache/doris/catalog/Column.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,23 @@ public class Column implements GsonPostProcessable {
public static final String HIDDEN_COLUMN_PREFIX = "__DORIS_";
// all shadow indexes should have this prefix in name
public static final String SHADOW_NAME_PREFIX = "__doris_shadow_";
public static final String IVM_HIDDEN_COLUMN_PREFIX = "__DORIS_IVM_";
// NOTE: you should name hidden column start with '__DORIS_' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
public static final String DELETE_SIGN = "__DORIS_DELETE_SIGN__";
public static final String WHERE_SIGN = "__DORIS_WHERE_SIGN__";
public static final String SEQUENCE_COL = "__DORIS_SEQUENCE_COL__";
public static final String ROWID_COL = "__DORIS_ROWID_COL__";
public static final String GLOBAL_ROWID_COL = "__DORIS_GLOBAL_ROWID_COL__";
public static final String IVM_ROW_ID_COL = "__DORIS_IVM_ROW_ID_COL__";
public static final String IVM_AGG_COUNT_COL = "__DORIS_IVM_AGG_COUNT_COL__";
public static final String IVM_DML_FACTOR_COL = "__DORIS_IVM_DML_FACTOR_COL__";
public static final String IVM_DELTA_GROUP_COUNT_COL = "__DORIS_IVM_DELTA_GROUP_COUNT_COL__";
/**
* Name of the binlog operation column in the base table that indicates insert (0) vs delete (1).
* When present, IVM delta rewrite derives dml_factor from this column instead of using the
* hardcoded literal 1. Follows the same convention as {@link #DELETE_SIGN}: 0 = insert, 1 = delete.
*/
public static final String BINLOG_OPERATION_COL = "binlog_op";
public static final String ROW_STORE_COL = "__DORIS_ROW_STORE_COL__";
public static final String VERSION_COL = "__DORIS_VERSION_COL__";
public static final String SKIP_BITMAP_COL = "__DORIS_SKIP_BITMAP_COL__";
Expand Down Expand Up @@ -209,6 +220,7 @@ public Column(String name, Type type, boolean isKey, AggregateType aggregateType
false, null, null, Sets.newHashSet(), null);
}


public Column(String name, Type type, boolean isKey, AggregateType aggregateType, boolean isAllowNull,
String defaultValue, String comment, boolean visible, int colUniqueId) {
this(name, type, isKey, aggregateType, isAllowNull, -1, defaultValue, comment, visible, null, colUniqueId, null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ materializedViewStatement
(BUCKETS (INTEGER_VALUE | AUTO))?)?
propertyClause?
AS? query #createMTMV
| REFRESH MATERIALIZED VIEW mvName=multipartIdentifier (partitionSpec | COMPLETE | AUTO) #refreshMTMV
| REFRESH MATERIALIZED VIEW mvName=multipartIdentifier
(partitionSpec | COMPLETE | AUTO | INCREMENTAL | PARTITIONS) #refreshMTMV
| ALTER MATERIALIZED VIEW mvName=multipartIdentifier ((RENAME newName=identifier)
| (REFRESH (refreshMethod | refreshTrigger | refreshMethod refreshTrigger))
| REPLACE WITH MATERIALIZED VIEW newName=identifier propertyClause?
Expand Down Expand Up @@ -1114,7 +1115,7 @@ refreshSchedule
;

refreshMethod
: COMPLETE | AUTO
: COMPLETE | AUTO | INCREMENTAL
;

mvPartition
Expand Down
3 changes: 3 additions & 0 deletions fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java
Original file line number Diff line number Diff line change
Expand Up @@ -1263,6 +1263,9 @@ public void processAlterMTMV(AlterMTMV alterMTMV, boolean isReplay) {
mtmv.compatible(Env.getCurrentEnv().getCatalogMgr());
}
break;
case ALTER_IVM_INFO:
mtmv.alterIvmInfo(alterMTMV.getIvmInfo());
break;
default:
throw new RuntimeException("Unknown type value: " + alterMTMV.getOpType());
}
Expand Down
46 changes: 39 additions & 7 deletions fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@
import org.apache.doris.mtmv.MTMVService;
import org.apache.doris.mtmv.MTMVStatus;
import org.apache.doris.mtmv.MTMVUtil;
import org.apache.doris.mtmv.ivm.IvmInfo;
import org.apache.doris.mtmv.ivm.IvmUtil;
import org.apache.doris.mysql.authenticate.AuthenticateType;
import org.apache.doris.mysql.authenticate.AuthenticatorManager;
import org.apache.doris.mysql.privilege.AccessControllerManager;
Expand Down Expand Up @@ -3755,16 +3757,29 @@ public static String getMTMVDdl(MTMV mtmv) throws AnalysisException {
"get table read lock timeout, database=" + mtmv.getDBName() + ",table=" + mtmv.getName());
}
try {
boolean isIvm = mtmv.isIvm();
StringBuilder sb = new StringBuilder("CREATE MATERIALIZED VIEW ");
sb.append(mtmv.getName());
addColNameAndComment(mtmv, sb);
addColNameAndComment(mtmv, sb, isIvm);
sb.append("\n");
sb.append(mtmv.getRefreshInfo());
addMTMVKeyInfo(mtmv, sb);
if (!isIvm) {
addMTMVKeyInfo(mtmv, sb);
}
addTableComment(mtmv, sb);
addMTMVPartitionInfo(mtmv, sb);
DistributionInfo distributionInfo = mtmv.getDefaultDistributionInfo();
sb.append("\n").append(distributionInfo.toSql());
if (isIvm) {
// IVM internally rewrites distribution to HASH(__DORIS_IVM_ROW_ID_COL__),
// which is a hidden column invisible to users. Output DISTRIBUTED BY RANDOM
// with the same bucket count / auto-bucket setting, so the DDL is re-executable
// and preserves the bucket configuration. On re-creation, the IVM pipeline
// will rewrite RANDOM to HASH(row_id) again automatically.
sb.append("\n").append(new RandomDistributionInfo(
distributionInfo.getBucketNum(), distributionInfo.getAutoBucket()).toSql());
} else {
sb.append("\n").append(distributionInfo.toSql());
}
// properties
sb.append("\nPROPERTIES (\n");
addOlapTablePropertyInfo(mtmv, sb, false, false, null);
Expand Down Expand Up @@ -3807,13 +3822,22 @@ private static void addMTMVPartitionInfo(MTMV mtmv, StringBuilder sb) throws Ana
}

private static void addColNameAndComment(TableIf tableIf, StringBuilder sb) {
addColNameAndComment(tableIf, sb, false);
}

private static void addColNameAndComment(TableIf tableIf, StringBuilder sb, boolean filterIvmHiddenCols) {
sb.append("\n(");
List<Column> columns = tableIf.getBaseSchema();
boolean first = true;
for (int i = 0; i < columns.size(); i++) {
if (i != 0) {
Column column = columns.get(i);
if (filterIvmHiddenCols && IvmUtil.isIvmHiddenColumn(column.getName())) {
continue;
}
if (!first) {
sb.append(",");
}
Column column = columns.get(i);
first = false;
sb.append(column.getName());
if (!StringUtils.isEmpty(column.getComment())) {
sb.append(" comment '");
Expand Down Expand Up @@ -3934,14 +3958,16 @@ private static void addOlapTablePropertyInfo(OlapTable olapTable, StringBuilder
}

// unique key table with merge on write, always print this property for unique table
if (olapTable.getKeysType() == KeysType.UNIQUE_KEYS) {
// but hide it for IVM materialized views (internal physical detail)
boolean isIvmMtmv = olapTable instanceof MTMV && ((MTMV) olapTable).isIvm();
if (olapTable.getKeysType() == KeysType.UNIQUE_KEYS && !isIvmMtmv) {
sb.append(",\n\"").append(PropertyAnalyzer.ENABLE_UNIQUE_KEY_MERGE_ON_WRITE).append("\" = \"");
sb.append(olapTable.getEnableUniqueKeyMergeOnWrite()).append("\"");
}

// enable_unique_key_skip_bitmap, always print this property for merge-on-write unique table
if (olapTable.getKeysType() == KeysType.UNIQUE_KEYS && olapTable.getEnableUniqueKeyMergeOnWrite()
&& olapTable.getEnableUniqueKeySkipBitmap()) {
&& olapTable.getEnableUniqueKeySkipBitmap() && !isIvmMtmv) {
sb.append(",\n\"").append(PropertyAnalyzer.ENABLE_UNIQUE_KEY_SKIP_BITMAP_COLUMN).append("\" = \"");
sb.append(olapTable.getEnableUniqueKeySkipBitmap()).append("\"");
}
Expand Down Expand Up @@ -7508,6 +7534,12 @@ public void addMTMVTaskResult(TableNameInfo mvName, MTMVTask task, MTMVRelation
this.alter.processAlterMTMV(alter, false);
}

public void alterMTMVIvmInfo(TableNameInfo mvName, IvmInfo ivmInfo) {
AlterMTMV alter = new AlterMTMV(mvName, MTMVAlterOpType.ALTER_IVM_INFO);
alter.setIvmInfo(ivmInfo);
this.alter.processAlterMTMV(alter, false);
}

// Ensure the env is ready, otherwise throw an exception.
public void checkReadyOrThrow() throws Exception {
if (isReady()) {
Expand Down
73 changes: 52 additions & 21 deletions fe/fe-core/src/main/java/org/apache/doris/catalog/MTMV.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.apache.doris.mtmv.MTMVPartitionInfo.MTMVPartitionType;
import org.apache.doris.mtmv.MTMVPartitionUtil;
import org.apache.doris.mtmv.MTMVPlanUtil;
import org.apache.doris.mtmv.MTMVPropertyUtil;
import org.apache.doris.mtmv.MTMVRefreshEnum.MTMVRefreshState;
import org.apache.doris.mtmv.MTMVRefreshEnum.MTMVState;
import org.apache.doris.mtmv.MTMVRefreshInfo;
Expand All @@ -44,18 +45,21 @@
import org.apache.doris.mtmv.MTMVRelation;
import org.apache.doris.mtmv.MTMVSnapshotIf;
import org.apache.doris.mtmv.MTMVStatus;
import org.apache.doris.mtmv.ivm.IvmInfo;
import org.apache.doris.mtmv.ivm.IvmUtil;
import org.apache.doris.nereids.rules.analysis.SessionVarGuardRewriter;
import org.apache.doris.qe.ConnectContext;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.google.gson.annotations.SerializedName;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
Expand Down Expand Up @@ -87,6 +91,8 @@ public class MTMV extends OlapTable {
private MTMVPartitionInfo mvPartitionInfo;
@SerializedName("rs")
private MTMVRefreshSnapshot refreshSnapshot;
@SerializedName("ii")
private IvmInfo ivmInfo;
// Should update after every fresh, not persist
// Cache with SessionVarGuardExpr: used when query session variables differ from MV creation variables
private MTMVCache cacheWithGuard;
Expand Down Expand Up @@ -120,6 +126,8 @@ public MTMV() {
this.mvPartitionInfo = params.mvPartitionInfo;
this.relation = params.relation;
this.refreshSnapshot = new MTMVRefreshSnapshot();
this.ivmInfo = new IvmInfo();
this.ivmInfo.setEnableIvm(params.enableIvm);
this.envInfo = new EnvInfo(-1L, -1L);
this.sessionVariables = params.sessionVariables;
mvRwLock = new ReentrantReadWriteLock(true);
Expand Down Expand Up @@ -207,6 +215,10 @@ public void processBaseViewChange(String schemaChangeDetail) {
}
}

public boolean isIvm() {
return getIvmInfo().isEnableIvm();
}

public boolean addTaskResult(MTMVTask task, MTMVRelation relation,
Map<String, MTMVRefreshPartitionSnapshot> partitionSnapshots, boolean isReplay) {
MTMVCache mtmvCacheWithGuard = null;
Expand Down Expand Up @@ -334,36 +346,20 @@ public int getRefreshPartitionNum() {
}

public Set<TableNameInfo> getExcludedTriggerTables() {
Set<TableNameInfo> res = Sets.newHashSet();
readMvLock();
try {
if (StringUtils.isEmpty(mvProperties.get(PropertyAnalyzer.PROPERTIES_EXCLUDED_TRIGGER_TABLES))) {
return res;
}
String[] split = mvProperties.get(PropertyAnalyzer.PROPERTIES_EXCLUDED_TRIGGER_TABLES).split(",");
for (String alias : split) {
res.add(new TableNameInfo(alias));
}
return res;
return MTMVPropertyUtil.parseTableNameInfos(
mvProperties.get(PropertyAnalyzer.PROPERTIES_EXCLUDED_TRIGGER_TABLES));
} finally {
readMvUnlock();
}
}

public Set<TableNameInfo> getQueryRewriteConsistencyRelaxedTables() {
Set<TableNameInfo> res = Sets.newHashSet();
readMvLock();
try {
String stillRewrittenTables
= mvProperties.get(PropertyAnalyzer.ASYNC_MV_QUERY_REWRITE_CONSISTENCY_RELAXED_TABLES);
if (StringUtils.isEmpty(stillRewrittenTables)) {
return res;
}
String[] split = stillRewrittenTables.split(",");
for (String alias : split) {
res.add(new TableNameInfo(alias));
}
return res;
return MTMVPropertyUtil.parseTableNameInfos(
mvProperties.get(PropertyAnalyzer.ASYNC_MV_QUERY_REWRITE_CONSISTENCY_RELAXED_TABLES));
} finally {
readMvUnlock();
}
Expand Down Expand Up @@ -437,6 +433,38 @@ public MTMVRefreshSnapshot getRefreshSnapshot() {
return refreshSnapshot;
}

public IvmInfo getIvmInfo() {
writeMvLock();
try {
if (ivmInfo == null) {
ivmInfo = new IvmInfo();
}
return ivmInfo;
} finally {
writeMvUnlock();
}
}

public void alterIvmInfo(IvmInfo ivmInfo) {
writeMvLock();
try {
this.ivmInfo = ivmInfo;
} finally {
writeMvUnlock();
}
}

public List<String> getInsertedColumnNames() {
List<Column> columns = getBaseSchema(true);
List<String> columnNames = Lists.newArrayListWithExpectedSize(columns.size());
for (Column column : columns) {
if (column.isVisible() || IvmUtil.isIvmHiddenColumn(column.getName())) {
columnNames.add(column.getName());
}
}
return columnNames;
}

public long getSchemaChangeVersion() {
readMvLock();
try {
Expand Down Expand Up @@ -612,6 +640,9 @@ public void gsonPostProcess() throws IOException {
if (sessionVariables == null) {
sessionVariables = Maps.newHashMap();
}
if (ivmInfo == null) {
ivmInfo = new IvmInfo();
}
Map<String, MTMVRefreshPartitionSnapshot> partitionSnapshots = refreshSnapshot.getPartitionSnapshots();
compatiblePctSnapshot(partitionSnapshots);
}
Expand Down
11 changes: 11 additions & 0 deletions fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -3468,6 +3468,17 @@ public long getVisibleVersion() throws RpcException {
}
}

/**
* Returns the visible TSO (timestamp ordering) for this table.
*
* <p>MOCK: currently returns {@link #getVisibleVersion()} directly. This will be
* replaced with a real TSO-based API once the storage layer supports it.
* Each partition's visible version and TSO will be in one-to-one correspondence.
*/
public long getVisibleTso() throws RpcException {
return getVisibleVersion();
}

// Get the table versions in batch.
public static List<Long> getVisibleVersionInBatch(List<OlapTable> tables) {
if (tables.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public OlapTableParams(boolean isTemporary) {
public static class MTMVParams extends BuildParams {
public MTMVRefreshInfo refreshInfo;
public String querySql;
public boolean enableIvm;
public Map<String, String> mvProperties;
public MTMVPartitionInfo mvPartitionInfo;
public MTMVRelation relation;
Expand Down Expand Up @@ -155,6 +156,14 @@ public OlapTableFactory withMvProperties(Map<String, String> mvProperties) {
return this;
}

public OlapTableFactory withEnableIvm(boolean enableIvm) {
Preconditions.checkState(params instanceof MTMVParams, "Invalid argument for "
+ params.getClass().getSimpleName());
MTMVParams mtmvParams = (MTMVParams) params;
mtmvParams.enableIvm = enableIvm;
return this;
}

private OlapTableFactory withRefreshInfo(MTMVRefreshInfo refreshInfo) {
Preconditions.checkState(params instanceof MTMVParams, "Invalid argument for "
+ params.getClass().getSimpleName());
Expand Down Expand Up @@ -194,6 +203,7 @@ public OlapTableFactory withExtraParams(CreateTableInfo createTableInfo) {
} else {
CreateMTMVInfo createMTMVInfo = (CreateMTMVInfo) createTableInfo;
return withRefreshInfo(createMTMVInfo.getRefreshInfo())
.withEnableIvm(createMTMVInfo.isEnableIvm())
.withQuerySql(createMTMVInfo.getQuerySql())
.withMvProperties(createMTMVInfo.getMvProperties())
.withMvPartitionInfo(createMTMVInfo.getMvPartitionInfo())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1612,7 +1612,10 @@ public void addPartition(Database db, String tableName, AddPartitionOp addPartit
partitionInfo.createAndCheckPartitionItem(singlePartitionDesc, isTempPartition);

// get distributionInfo
List<Column> baseSchema = olapTable.getBaseSchema();
// Use full schema (including hidden columns) so that distribution columns
// such as __DORIS_IVM_ROW_ID_COL__ (hidden but used as hash distribution key
// for IVM materialized views) can be resolved correctly.
List<Column> baseSchema = olapTable.getBaseSchema(true);
DistributionInfo defaultDistributionInfo = olapTable.getDefaultDistributionInfo();
if (distributionDesc != null) {
distributionInfo = distributionDesc.toDistributionInfo(baseSchema);
Expand Down
Loading
Loading