diff --git a/fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java b/fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java index 4c91900423..162f22456a 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java +++ b/fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java @@ -542,8 +542,9 @@ public class Alter { long newTblId = log.getNewTblId(); Database db = Env.getCurrentInternalCatalog().getDbOrMetaException(dbId); - OlapTable origTable = (OlapTable) db.getTableOrMetaException(origTblId, TableType.OLAP); - OlapTable newTbl = (OlapTable) db.getTableOrMetaException(newTblId, TableType.OLAP); + List tableTypes = Lists.newArrayList(TableType.OLAP, TableType.MATERIALIZED_VIEW); + OlapTable origTable = (OlapTable) db.getTableOrMetaException(origTblId, tableTypes); + OlapTable newTbl = (OlapTable) db.getTableOrMetaException(newTblId, tableTypes); List tableList = Lists.newArrayList(origTable, newTbl); tableList.sort((Comparator.comparing(Table::getId))); MetaLockUtils.writeLockTablesOrMetaException(tableList); diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/DatabaseIf.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/DatabaseIf.java index f0dfa53484..3e915ce437 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/DatabaseIf.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/DatabaseIf.java @@ -181,6 +181,16 @@ public interface DatabaseIf { return table; } + default T getTableOrMetaException(long tableId, List tableTypes) + throws MetaNotFoundException { + T table = getTableOrMetaException(tableId); + if (!tableTypes.contains(table.getType())) { + throw new MetaNotFoundException( + "Tye type of " + tableId + " doesn't match, expected data tables=" + tableTypes); + } + return table; + } + default T getTableOrDdlException(String tableName) throws DdlException { return getTableOrException(tableName, t -> new DdlException(ErrorCode.ERR_BAD_TABLE_ERROR.formatErrorMsg(t))); }