Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 12 additions & 4 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 @@ -206,8 +206,6 @@ private boolean processAlterOlapTable(AlterTableStmt stmt, OlapTable olapTable,
} else if (currentAlterOps.hasSchemaChangeOp()) {
// if modify storage type to v2, do schema change to convert all related tablets to segment v2 format
schemaChangeHandler.process(stmt.toSql(), alterClauses, db, olapTable);
// if base table schemaChanged, need change mtmv status
Env.getCurrentEnv().getMtmvService().alterTable(olapTable);
} else if (currentAlterOps.hasRollupOp()) {
materializedViewHandler.process(alterClauses, db, olapTable);
} else if (currentAlterOps.hasPartitionOp()) {
Expand Down Expand Up @@ -263,7 +261,6 @@ private boolean processAlterOlapTable(AlterTableStmt stmt, OlapTable olapTable,
}
} else if (currentAlterOps.hasRenameOp()) {
processRename(db, olapTable, alterClauses);
Env.getCurrentEnv().getMtmvService().alterTable(olapTable);
} else if (currentAlterOps.hasReplaceTableOp()) {
processReplaceTable(db, olapTable, alterClauses);
} else if (currentAlterOps.contains(AlterOpType.MODIFY_TABLE_PROPERTY_SYNC)) {
Expand All @@ -282,10 +279,21 @@ private boolean processAlterOlapTable(AlterTableStmt stmt, OlapTable olapTable,
} else {
throw new DdlException("Invalid alter operations: " + currentAlterOps);
}

if (needChangeMTMVState(alterClauses)) {
Env.getCurrentEnv().getMtmvService().alterTable(olapTable);
}
return needProcessOutsideTableLock;
}

private boolean needChangeMTMVState(List<AlterClause> alterClauses) {
for (AlterClause alterClause : alterClauses) {
if (alterClause.needChangeMTMVState()) {
return true;
}
}
return false;
}

private void processModifyTableComment(Database db, OlapTable tbl, AlterClause alterClause)
throws DdlException {
tbl.writeLockOrDdlException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ public boolean allowOpMTMV() {
return false;
}

@Override
public boolean needChangeMTMVState() {
return false;
}

@Override
public String toSql() {
StringBuilder sb = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ public boolean allowOpMTMV() {
return false;
}

@Override
public boolean needChangeMTMVState() {
return false;
}

@Override
public String toSql() {
StringBuilder sb = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ public boolean allowOpMTMV() {
return false;
}

@Override
public boolean needChangeMTMVState() {
return false;
}

@Override
public String toSql() {
StringBuilder sb = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ public boolean allowOpMTMV() {
return false;
}

@Override
public boolean needChangeMTMVState() {
return false;
}

@Override
public String toSql() {
StringBuilder sb = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ public boolean allowOpMTMV() {
return true;
}

@Override
public boolean needChangeMTMVState() {
return false;
}

@Override
public String toSql() {
StringBuilder stringBuilder = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,8 @@ public AlterOpType getOpType() {
public boolean allowOpMTMV() {
return true;
}

public boolean needChangeMTMVState() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ public void setTableName(TableName tableName) {
}

public abstract boolean allowOpMTMV();

public abstract boolean needChangeMTMVState();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this may be add a default impl and value such as true, when add new cluse later, maybe safe

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intentional to avoid ignoring this method when creating new classes, and adding some comments in other PRs

}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ public boolean allowOpMTMV() {
return true;
}

@Override
public boolean needChangeMTMVState() {
return false;
}

@Override
public String toSql() {
if (alter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ public boolean allowOpMTMV() {
return false;
}

@Override
public boolean needChangeMTMVState() {
return true;
}

@Override
public String toSql() {
return "RENAME COLUMN " + colName + " " + newColName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ public boolean allowOpMTMV() {
return true;
}

@Override
public boolean needChangeMTMVState() {
return false;
}

@Override
public String toSql() {
if (alter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ public boolean allowOpMTMV() {
return false;
}

@Override
public boolean needChangeMTMVState() {
return true;
}

@Override
public String toSql() {
StringBuilder sb = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ public boolean allowOpMTMV() {
return true;
}

@Override
public boolean needChangeMTMVState() {
return false;
}

@Override
public String toSql() {
StringBuilder stringBuilder = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ public boolean allowOpMTMV() {
return false;
}

@Override
public boolean needChangeMTMVState() {
return false;
}

@Override
public String toSql() {
StringBuilder sb = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ public boolean allowOpMTMV() {
return false;
}

@Override
public boolean needChangeMTMVState() {
return false;
}

@Override
public String toSql() {
StringBuilder sb = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ public boolean allowOpMTMV() {
return true;
}

@Override
public boolean needChangeMTMVState() {
return false;
}

@Override
public String toSql() {
StringBuilder stringBuilder = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ public boolean allowOpMTMV() {
return true;
}

@Override
public boolean needChangeMTMVState() {
return false;
}

@Override
public String toSql() {
StringBuilder sb = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ public boolean allowOpMTMV() {
return false;
}

@Override
public boolean needChangeMTMVState() {
return true;
}

@Override
public String toSql() {
StringBuilder sb = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ public boolean allowOpMTMV() {
return false;
}

@Override
public boolean needChangeMTMVState() {
return false;
}

@Override
public String toSql() {
StringBuilder sb = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ public boolean allowOpMTMV() {
return true;
}

@Override
public boolean needChangeMTMVState() {
return false;
}

@Override
public String toSql() {
StringBuilder sb = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ public boolean allowOpMTMV() {
return false;
}

@Override
public boolean needChangeMTMVState() {
return false;
}

@Override
public String toSql() {
StringBuilder sb = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ public boolean allowOpMTMV() {
return false;
}

@Override
public boolean needChangeMTMVState() {
return false;
}

@Override
public String toSql() {
StringBuilder sb = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ public boolean allowOpMTMV() {
return true;
}

@Override
public boolean needChangeMTMVState() {
return false;
}

@Override
public String toSql() {
StringBuilder sb = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,11 @@ public boolean allowOpMTMV() {
return true;
}

@Override
public boolean needChangeMTMVState() {
return false;
}

@Override
public String toSql() {
StringBuilder sb = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ public boolean allowOpMTMV() {
return false;
}

@Override
public boolean needChangeMTMVState() {
return false;
}

@Override
public String toSql() {
return "RENAME PARTITION " + partitionName + " " + newPartitionName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ public boolean allowOpMTMV() {
return false;
}

@Override
public boolean needChangeMTMVState() {
return false;
}

@Override
public String toSql() {
StringBuilder sb = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ public boolean allowOpMTMV() {
return false;
}

@Override
public boolean needChangeMTMVState() {
return false;
}

@Override
public String toSql() {
StringBuilder sb = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ public boolean allowOpMTMV() {
return false;
}

@Override
public boolean needChangeMTMVState() {
return true;
}

@Override
public String toSql() {
StringBuilder sb = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ public boolean allowOpMTMV() {
return true;
}

@Override
public boolean needChangeMTMVState() {
return false;
}

@Override
public String toSql() {
return "RENAME ROLLUP " + rollupName + " " + newRollupName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ public boolean allowOpMTMV() {
return false;
}

@Override
public boolean needChangeMTMVState() {
return true;
}

@Override
public String toSql() {
return "RENAME " + newTableName;
Expand Down
Loading