morningman commented on a change in pull request #3068: Support delete
materialized view
URL: https://github.com/apache/incubator-doris/pull/3068#discussion_r390315531
##########
File path: fe/src/main/java/org/apache/doris/alter/Alter.java
##########
@@ -107,24 +114,38 @@ public void
processCreateMaterializedView(CreateMaterializedViewStmt stmt) throw
throw new DdlException("Do not support alter non-OLAP table["
+ tableName + "]");
}
OlapTable olapTable = (OlapTable) table;
+ olapTable.checkStableAndNormal(db.getClusterName());
- if (olapTable.getState() != OlapTableState.NORMAL) {
- throw new DdlException("Table[" + table.getName() + "]'s state
is not NORMAL. "
- + "Do not allow doing
materialized view");
+
((MaterializedViewHandler)materializedViewHandler).processCreateMaterializedView(stmt,
db, olapTable);
+ } finally {
+ db.writeUnlock();
+ }
+ }
+
+ public void processDropMaterializedView(DropMaterializedViewStmt stmt)
throws DdlException, MetaNotFoundException {
+ // check db
+ String dbName = stmt.getTableName().getDb();
+ Database db = Catalog.getInstance().getDb(dbName);
+ if (db == null) {
+ ErrorReport.reportDdlException(ErrorCode.ERR_BAD_DB_ERROR, dbName);
+ }
+
+ db.writeLock();
+ try {
+ String tableName = stmt.getTableName().getTbl();
+ Table table = db.getTable(tableName);
+ if (table == null) {
+ ErrorReport.reportDdlException(ErrorCode.ERR_BAD_TABLE_ERROR,
tableName);
}
- // check if all tablets are healthy, and no tablet is in tablet
scheduler
- boolean isStable =
olapTable.isStable(Catalog.getCurrentSystemInfo(),
-
Catalog.getCurrentCatalog().getTabletScheduler(),
- db.getClusterName());
- if (!isStable) {
- throw new DdlException("table [" + olapTable.getName() + "] is
not stable."
- + " Some tablets of this table
may not be healthy or are being "
- + "scheduled."
- + " You need to repair the
table first"
- + " or stop cluster balance.
See 'help admin;'.");
+
+ if (table.getType() != TableType.OLAP) {
+ throw new DdlException("Do not support non-OLAP table [" +
tableName + "] when drop materialized view");
}
-
((MaterializedViewHandler)materializedViewHandler).processCreateMaterializedView(stmt,
db, olapTable);
+ OlapTable olapTable = (OlapTable) table;
+ olapTable.checkStableAndNormal(db.getClusterName());
Review comment:
No need to check table's stable when dropping mv.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]