zddr commented on code in PR #53129:
URL: https://github.com/apache/doris/pull/53129#discussion_r2200375201
##########
fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4:
##########
@@ -94,8 +94,8 @@ materializedViewStatement
| (REFRESH (refreshMethod | refreshTrigger | refreshMethod
refreshTrigger))
| REPLACE WITH MATERIALIZED VIEW newName=identifier propertyClause?
| (SET LEFT_PAREN fileProperties=propertyItemList RIGHT_PAREN))
#alterMTMV
- | DROP MATERIALIZED VIEW (IF EXISTS)? mvName=multipartIdentifier
- (ON tableName=multipartIdentifier)?
#dropMTMV
+ | DROP MATERIALIZED VIEW (IF EXISTS)? mvName=multipartIdentifier
#dropMTMV
+ | DROP MATERIALIZED VIEW (IF EXISTS)? mvName=identifierOrText ON
tableName=multipartIdentifier #dropMaterializedView
Review Comment:
Fixed
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/DropMaterializedViewCommand.java:
##########
@@ -15,80 +15,77 @@
// specific language governing permissions and limitations
// under the License.
-package org.apache.doris.analysis;
+package org.apache.doris.nereids.trees.plans.commands;
+import org.apache.doris.analysis.StmtType;
import org.apache.doris.catalog.Env;
import org.apache.doris.common.AnalysisException;
import org.apache.doris.common.ErrorCode;
import org.apache.doris.common.ErrorReport;
-import org.apache.doris.common.UserException;
import org.apache.doris.common.util.Util;
import org.apache.doris.mysql.privilege.PrivPredicate;
+import org.apache.doris.nereids.trees.plans.PlanType;
+import org.apache.doris.nereids.trees.plans.commands.info.TableNameInfo;
+import org.apache.doris.nereids.trees.plans.visitor.PlanVisitor;
import org.apache.doris.qe.ConnectContext;
+import org.apache.doris.qe.StmtExecutor;
-import com.google.common.base.Strings;
+import com.google.common.annotations.VisibleForTesting;
+
+import java.util.Objects;
/**
- * DROP MATERIALIZED VIEW [ IF EXISTS ] <mv_name> ON [db_name].<table_name>
- *
- * Parameters
- * IF EXISTS: Do not throw an error if the materialized view does not exist. A
notice is issued in this case.
- * mv_name: The name of the materialized view to remove.
- * db_name: The name of db to which materialized view belongs.
- * table_name: The name of table to which materialized view belongs.
+ * drop sync materialized view
*/
-public class DropMaterializedViewStmt extends DdlStmt implements
NotFallbackInParser {
-
- private String mvName;
- private TableName tableName;
- private boolean ifExists;
+public class DropMaterializedViewCommand extends Command implements
ForwardWithSync {
+ private final TableNameInfo tableName;
+ private final boolean ifExists;
+ private final String mvName;
- public DropMaterializedViewStmt(boolean ifExists, String mvName, TableName
tableName) {
- this.mvName = mvName;
- this.tableName = tableName;
+ public DropMaterializedViewCommand(TableNameInfo tableName, boolean
ifExists, String mvName) {
+ super(PlanType.DROP_MATERIALIZED_VIEW_COMMAND);
+ this.tableName = Objects.requireNonNull(tableName, "require tableName
object");
this.ifExists = ifExists;
+ this.mvName = Objects.requireNonNull(mvName, "require mvName object");
}
- public String getMvName() {
- return mvName;
- }
-
- public TableName getTableName() {
- return tableName;
- }
-
- public boolean isIfExists() {
- return ifExists;
+ @Override
+ public void run(ConnectContext ctx, StmtExecutor executor) throws
Exception {
+ validate(ctx);
+ Env.getCurrentEnv().dropMaterializedView(this);
}
- @Override
- public void analyze(Analyzer analyzer) throws UserException {
- if (Strings.isNullOrEmpty(mvName)) {
- throw new AnalysisException("The materialized name could not be
empty or null.");
- }
- tableName.analyze(analyzer);
+ /**
+ * validate
+ */
+ @VisibleForTesting
+ public void validate(ConnectContext ctx) throws AnalysisException {
// disallow external catalog
Review Comment:
Fixed
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]