EmmyMiao87 commented on a change in pull request #4253:
URL: https://github.com/apache/incubator-doris/pull/4253#discussion_r472123863



##########
File path: 
fe/fe-core/src/main/java/org/apache/doris/analysis/DropMaterializedViewStmt.java
##########
@@ -38,38 +43,91 @@
  */
 public class DropMaterializedViewStmt extends DdlStmt {
 
-    private String mvName;
-    private TableName tableName;
     private boolean ifExists;
+    private final TableName dbMvName;
+    private final TableName dbTblName;
 
-    public DropMaterializedViewStmt(boolean ifExists, String mvName, TableName 
tableName) {
-        this.mvName = mvName;
-        this.tableName = tableName;
+    public DropMaterializedViewStmt(boolean ifExists, TableName dbMvName, 
TableName dbTblName) {
         this.ifExists = ifExists;
+        this.dbMvName = dbMvName;
+        this.dbTblName = dbTblName;
+    }
+
+    public boolean isSetIfExists() {
+        return ifExists;
     }
 
     public String getMvName() {
-        return mvName;
+        return dbMvName.getTbl();
     }
 
-    public TableName getTableName() {
-        return tableName;
+    public String getTblName() {
+        if (dbTblName != null) {
+            return dbTblName.getTbl();
+        } else {
+            return null;
+        }
     }
 
-    public boolean isIfExists() {
-        return ifExists;
+    public String getDbName() {
+        if (dbTblName != null) {
+            return dbTblName.getDb();
+        } else {
+            return dbMvName.getDb();
+        }
     }
 
     @Override
     public void analyze(Analyzer analyzer) throws UserException {
-        if (Strings.isNullOrEmpty(mvName)) {
-            throw new AnalysisException("The materialized name could not be 
empty or null.");
+        if (dbTblName != null && !Strings.isNullOrEmpty(dbMvName.getDb())) {
+            throw new AnalysisException("Syntax drop materialized view 
[mv-name] from db.name mush specify database name explicitly in `from`");

Review comment:
       If the dbTableName is different from dbMvName.getDb(), the Doris will 
thrown Exception.

##########
File path: 
fe/fe-core/src/main/java/org/apache/doris/analysis/DropMaterializedViewStmt.java
##########
@@ -38,38 +43,91 @@
  */
 public class DropMaterializedViewStmt extends DdlStmt {
 
-    private String mvName;
-    private TableName tableName;
     private boolean ifExists;
+    private final TableName dbMvName;
+    private final TableName dbTblName;
 
-    public DropMaterializedViewStmt(boolean ifExists, String mvName, TableName 
tableName) {
-        this.mvName = mvName;
-        this.tableName = tableName;
+    public DropMaterializedViewStmt(boolean ifExists, TableName dbMvName, 
TableName dbTblName) {
         this.ifExists = ifExists;
+        this.dbMvName = dbMvName;
+        this.dbTblName = dbTblName;
+    }
+
+    public boolean isSetIfExists() {
+        return ifExists;
     }
 
     public String getMvName() {
-        return mvName;
+        return dbMvName.getTbl();
     }
 
-    public TableName getTableName() {
-        return tableName;
+    public String getTblName() {
+        if (dbTblName != null) {
+            return dbTblName.getTbl();
+        } else {
+            return null;
+        }
     }
 
-    public boolean isIfExists() {
-        return ifExists;
+    public String getDbName() {
+        if (dbTblName != null) {
+            return dbTblName.getDb();
+        } else {
+            return dbMvName.getDb();
+        }
     }
 
     @Override
     public void analyze(Analyzer analyzer) throws UserException {
-        if (Strings.isNullOrEmpty(mvName)) {
-            throw new AnalysisException("The materialized name could not be 
empty or null.");
+        if (dbTblName != null && !Strings.isNullOrEmpty(dbMvName.getDb())) {
+            throw new AnalysisException("Syntax drop materialized view 
[mv-name] from db.name mush specify database name explicitly in `from`");
+        }
+        if (dbTblName != null) {
+            if (!Strings.isNullOrEmpty(dbMvName.getDb())) {
+                throw new AnalysisException("If the database appears after the 
from statement, " +

Review comment:
       What's the difference between here and above?




----------------------------------------------------------------
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]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to