This is an automated email from the ASF dual-hosted git repository.

adonisling pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 82e2102e18 [fix](MTMV) Exceptions occur when dropping meterialized 
view with if exists (#15568)
82e2102e18 is described below

commit 82e2102e18df5fddc62984e61815cc28a08fedaa
Author: chenlinzhong <490103...@qq.com>
AuthorDate: Tue Jan 17 15:29:39 2023 +0800

    [fix](MTMV) Exceptions occur when dropping meterialized view with if exists 
(#15568)
---
 .../main/java/org/apache/doris/alter/Alter.java    | 29 +++++++++++++++-------
 1 file changed, 20 insertions(+), 9 deletions(-)

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 162f22456a..d9b7b9bd12 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
@@ -138,15 +138,26 @@ public class Alter {
             throw new DdlException("Drop materialized view without table name 
is unsupported : " + stmt.toSql());
         }
         TableName tableName = !stmt.isForMTMV() ? stmt.getTableName() : 
stmt.getMTMVName();
-
-        // check db
-        String dbName = tableName.getDb();
-        Database db = 
Env.getCurrentInternalCatalog().getDbOrDdlException(dbName);
-
-        String name = tableName.getTbl();
-        OlapTable olapTable = (OlapTable) db.getTableOrMetaException(name,
-                !stmt.isForMTMV() ? TableType.OLAP : 
TableType.MATERIALIZED_VIEW);
-
+        Database db;
+        OlapTable olapTable;
+        if (stmt.isIfExists()) {
+            try {
+                String dbName = tableName.getDb();
+                db = 
Env.getCurrentInternalCatalog().getDbOrDdlException(dbName);
+                String name = tableName.getTbl();
+                olapTable = (OlapTable) db.getTableOrMetaException(name,
+                        !stmt.isForMTMV() ? TableType.OLAP : 
TableType.MATERIALIZED_VIEW);
+            } catch (Exception e) {
+                LOG.info("db or table not exists, msg={}", e.getMessage());
+                return;
+            }
+        } else {
+            String dbName = tableName.getDb();
+            db = Env.getCurrentInternalCatalog().getDbOrDdlException(dbName);
+            String name = tableName.getTbl();
+            olapTable = (OlapTable) db.getTableOrMetaException(name,
+                    !stmt.isForMTMV() ? TableType.OLAP : 
TableType.MATERIALIZED_VIEW);
+        }
         // drop materialized view
         if (!stmt.isForMTMV()) {
             ((MaterializedViewHandler) 
materializedViewHandler).processDropMaterializedView(stmt, db, olapTable);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to