Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
0d46a3d
[feat](ivm) Add mtmv increment refresh framework
yujun777 Mar 17, 2026
d6a151d
[feature](mtmv) add nereids ivm rewrite gate and tests
yujun777 Mar 17, 2026
a904e67
[feature](ivm) add refresh manager entry point
yujun777 Mar 17, 2026
25ba507
[ivm] make plan analysis an analysis artifact
yujun777 Mar 17, 2026
e309e3f
Add thin IVM stream metadata precheck
yujun777 Mar 17, 2026
4087adb
[ivm] fix IVMRefreshResult null contract, add toString and fallback l…
yujun777 Mar 17, 2026
e948054
[ivm] replace DeltaPlanBundle description string with LogicalPlan and…
yujun777 Mar 18, 2026
b84ca2b
[ivm] replace ivmPlanAnalysis with ivmDeltaBundles in CascadesContext
yujun777 Mar 18, 2026
c568171
[ivm] replace plan analyzer/dispatcher with Nereids delta rules
yujun777 Mar 18, 2026
eac9d65
[ivm] refactor IVM Nereids rules: normalize + delta rule skeletons
yujun777 Mar 18, 2026
ef67ea2
[ivm] introduce IvmAnalyzeMode and split IVM session variables
yujun777 Mar 18, 2026
f227949
[ivm] implement IvmNormalizeMtmvPlan row-id injection and IvmContext
yujun777 Mar 18, 2026
2cf7b97
[ivm] wire row-id column into CreateMTMVInfo and add UTs
yujun777 Mar 18, 2026
e3c4b73
[ivm] make IVM MV UNIQUE_KEYS+MOW and add key-type UTs
yujun777 Mar 18, 2026
7ecf979
Rename IVM delta bundle to command bundle
yujun777 Mar 18, 2026
20f3ff9
[ivm] remove mv_ prefix from IVM row-id column name
yujun777 Mar 18, 2026
3228fce
[ivm] move delta calculation outside Nereids and add skeleton IvmDelt…
yujun777 Mar 18, 2026
fb7cd7e
[ivm] implement scan & project-scan delta rewriting in IvmDeltaRewriter
yujun777 Mar 18, 2026
e6238dc
[ivm] convert IVMDeltaExecutor and IVMCapabilityChecker from interfac…
yujun777 Mar 18, 2026
26aeda6
[ivm] integrate IVM refresh into MTMVTask run flow
yujun777 Mar 18, 2026
ab05bfc
[ivm] extract MTMVPlanUtil.executeCommand() and add audit log to IVMD…
yujun777 Mar 19, 2026
c73f52e
fix ivm refresh insert table command fail
yujun777 Mar 19, 2026
beedac9
[improvement](fe) Centralize IVM hidden column names
yujun777 Mar 19, 2026
125a36b
[fix](fe) Remove unused MTMV imports
yujun777 Mar 19, 2026
9963277
[fix](fe) Preserve IVM row id in incremental mtmv refresh
yujun777 Mar 22, 2026
94727e5
[fix](fe) Refresh root fragment output exprs
yujun777 Mar 22, 2026
91a5b4e
[fix](fe) Disable DML MV rewrite during MTMV refresh
yujun777 Mar 22, 2026
e41fd63
[fix](fe) Normalize incremental MTMV sink outputs
yujun777 Mar 24, 2026
89bc2c7
[fix](fe) Fix redundant guard and checkstyle in incremental MTMV sink…
yujun777 Mar 24, 2026
ac802cb
[refactor](fe) Rename IVM normalize MTMV rule
yujun777 Mar 26, 2026
3387044
[test](fe) Update FE unit test expectations
yujun777 Mar 26, 2026
92b4f20
[fix](fe) Reuse aggregate output alias slot for expression group keys
yujun777 Mar 26, 2026
bd10525
[fix](fe) Check translated output slot refs
yujun777 Mar 26, 2026
fc7b3f2
[fix](fe) Restore view alias rewrite guard for simpleColumnDefinitions
yujun777 Mar 26, 2026
565f156
[fix](fe) Preserve deferred TopN projected outputs
yujun777 Mar 27, 2026
6884e3f
[fix](fe) Limit MTMV alias rewrite to incremental refresh
yujun777 Mar 27, 2026
25ef157
[fix](fe) Create MTMV context before StatementContext in refresh
yujun777 Mar 27, 2026
20ae568
[feature](fe) Add IVM aggregate normalization support
yujun777 Mar 31, 2026
a456f2f
[refactor](fe) Rename IVM-prefixed classes to Ivm in mtmv/ivm package
yujun777 Mar 31, 2026
116c0e5
[refactor](fe) Extract MTMV test cases from CreateTableCommandTest in…
yujun777 Mar 31, 2026
4fe81e6
[refactor](fe) Split testConvertToPartitionTableInfo into four separa…
yujun777 Mar 31, 2026
ee04101
[improvement](fe) Propagate IvmNormalizeResult through delta rewrite …
yujun777 Apr 2, 2026
61ea18f
[refactor](fe) Extract IvmDeltaStrategy interface and AbstractDeltaSt…
yujun777 Apr 2, 2026
a6b7d94
[test](fe) Add aggregate IMMV creation test cases in CreateMTMVComman…
yujun777 Apr 2, 2026
9a9d3dc
[feature](fe) Add IVM agg delta rewrite strategies
yujun777 Apr 7, 2026
5a572a2
[fix](fe) Reuse MOW hidden columns for IVM MTMV
yujun777 Apr 7, 2026
f6d89ce
[refactor](fe) Rename IVM fallback and delta bundle types
yujun777 Apr 8, 2026
669b355
[fix](fe) Persist IVM identity in MTMV metadata
yujun777 Apr 8, 2026
2e79f79
[feature](fe) Support explicit REFRESH MATERIALIZED VIEW ... INCREMEN…
seawinde Apr 8, 2026
17176da
[fix](ivm) Ivm validate columns fix when create incremental mv (#3)
seawinde Apr 9, 2026
d4fef8e
[refactor](fe) Rename MvNondeterministicFunctionCollector back to Non…
yujun777 Apr 10, 2026
ac329cf
[fix](fe) Hide physical UNIQUE KEY and row-id columns in SHOW CREATE …
seawinde Apr 10, 2026
3725a04
[refactor](fe) Consolidate isIvmHiddenColumn into IvmUtil
yujun777 Apr 12, 2026
9c9d300
[fix](fe) Fix IVM row duplication by enforcing HASH distribution on r…
yujun777 Apr 12, 2026
9a306f9
[test](fe,regression) Add IVM distribution override UTs and DUP_KEYS …
yujun777 Apr 12, 2026
65f91b4
[fix](fe) Fix three IVM INCREMENTAL refresh bugs (null detail, null d…
yujun777 Apr 12, 2026
32c727b
[test](regression) Add scalar aggregate IVM regression test
yujun777 Apr 12, 2026
09207ba
[feature](fe) Add MIN/MAX aggregate support for IVM incremental refresh
yujun777 Apr 12, 2026
09fa503
(fe) Fix stale Javadoc, remove dead code, and enhance IVM MIN/MAX reg…
yujun777 Apr 13, 2026
aa11d06
[improvement](fe) IVM SHOW CREATE outputs DISTRIBUTED BY RANDOM inste…
yujun777 Apr 13, 2026
a37167d
[doc](fe) Add IVM AGENTS.md with testing guidelines and development n…
yujun777 Apr 13, 2026
1cc6d22
[fix](fe) Fix NPE in MTMV refresh when definition SQL contains SET_VA…
yujun777 Apr 13, 2026
004e247
[feature](ivm) Derive dml_factor from binlog_op column and fix assert…
yujun777 Apr 13, 2026
e52d089
[refactor](fe) Extract common methods from IvmAggDeltaStrategy and do…
yujun777 Apr 13, 2026
457102c
[test](regression) add NULL value regression tests for IVM aggregation
yujun777 Apr 13, 2026
48a0680
[test](regression) Add IVM agg regression tests for group deletion, s…
yujun777 Apr 13, 2026
e34e47a
[test](fe) Add IVM agg gap tests and fix AVG(DECIMAL) ClassCastException
yujun777 Apr 13, 2026
22bd40e
move regression case to mtmv_p0/ivm
yujun777 Apr 13, 2026
5f75ccf
[fix](fe) Fix null group key row_id collision in IVM
yujun777 Apr 14, 2026
af28b47
[improvement](fe) Support expression arguments in IVM aggregate funct…
yujun777 Apr 14, 2026
661fac0
[refactor](fe) Replace raw string keys with StateKey enum in IVM agg …
yujun777 Apr 14, 2026
0c48f15
[improvement](fe) Improve IVM MIN/MAX boundary failure diagnosis
yujun777 Apr 14, 2026
f44fcc2
[feature](fe) Support bare GROUP BY without aggregate functions in IVM
yujun777 Apr 14, 2026
ce9a709
[test](regression) Add INCREMENTAL output assertions to IVM agg regre…
yujun777 Apr 14, 2026
0a428d2
[doc](fe) Merge IVM regression test binlog_op guide into FE IVM AGENT…
yujun777 Apr 14, 2026
e7a413a
[test](fe) Replace IVM FE unit tests with Mockito
yujun777 Apr 14, 2026
b3f2226
[fix](fe) Replace remaining JMockit usage with Mockito in IvmRefreshM…
yujun777 Apr 15, 2026
4289d9c
[refactor](fe) Remove redundant hidden IVM columns for COUNT/SUM/MIN/MAX
yujun777 Apr 15, 2026
aa55380
[refactor](fe) Merge COUNT_STAR/COUNT_EXPR into COUNT, replace StateK…
yujun777 Apr 15, 2026
35597b3
[fix](fe) Fix import issues after rebase onto upstream/master
yujun777 Apr 16, 2026
01a3d10
[improvement](fe) Clean up COUNT branch and use isCountStar() for rob…
yujun777 Apr 16, 2026
b25e684
[improvement](fe) Add MIN/MAX guard bypass when non-null count drops …
yujun777 Apr 16, 2026
af2a553
Ivm pick create alter validation (#6)
seawinde Apr 16, 2026
d01f079
[improvement](fe) Clean up IVM normalize and alter refresh error mess…
yujun777 Apr 17, 2026
da2da16
[feature](ivm) Implement multi-bundle delta plan generation (Steps 1-5)
yujun777 Apr 17, 2026
8ced36a
[feature](fe) Add runningIvmRefresh flag with editlog persistence and…
yujun777 Apr 17, 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 @@ -1262,6 +1262,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 @@ -3739,16 +3741,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 @@ -3791,13 +3806,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 @@ -3918,14 +3942,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 @@ -7491,6 +7517,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