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

starocean999 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 08dda65aea7 [Chore](nereids) remove AlterViewStmt and CreateViewStmt 
(#53508)
08dda65aea7 is described below

commit 08dda65aea7d12711a35375be5df5e98ba9a0f28
Author: yaoxiao <yx136264...@163.com>
AuthorDate: Tue Jul 22 17:18:49 2025 +0800

    [Chore](nereids) remove AlterViewStmt and CreateViewStmt (#53508)
---
 .../main/java/org/apache/doris/alter/Alter.java    | 13 ----
 .../org/apache/doris/analysis/AlterViewStmt.java   | 74 ----------------------
 .../org/apache/doris/analysis/CreateViewStmt.java  | 73 ---------------------
 .../main/java/org/apache/doris/catalog/Env.java    | 57 -----------------
 .../doris/catalog/MysqlCompatibleDatabase.java     |  4 +-
 .../trees/plans/commands/info/AlterViewInfo.java   |  2 +-
 .../trees/plans/commands/info/CreateViewInfo.java  |  2 +-
 .../main/java/org/apache/doris/qe/DdlExecutor.java |  6 --
 8 files changed, 4 insertions(+), 227 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 9e5fc8230ee..54b13a98c33 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
@@ -24,7 +24,6 @@ import org.apache.doris.analysis.AddPartitionLikeClause;
 import org.apache.doris.analysis.AlterClause;
 import org.apache.doris.analysis.AlterMultiPartitionClause;
 import org.apache.doris.analysis.AlterTableStmt;
-import org.apache.doris.analysis.AlterViewStmt;
 import org.apache.doris.analysis.ColumnRenameClause;
 import org.apache.doris.analysis.CreateMaterializedViewStmt;
 import org.apache.doris.analysis.CreateOrReplaceBranchClause;
@@ -915,18 +914,6 @@ public class Alter {
                 alterViewInfo.getColumns(), alterViewInfo.getComment());
     }
 
-    public void processAlterView(AlterViewStmt stmt, ConnectContext ctx) 
throws UserException {
-        TableName dbTableName = stmt.getTbl();
-        String dbName = dbTableName.getDb();
-
-        Database db = 
Env.getCurrentInternalCatalog().getDbOrDdlException(dbName);
-
-        String tableName = dbTableName.getTbl();
-        View view = (View) db.getTableOrMetaException(tableName, 
TableType.VIEW);
-        modifyViewDef(db, view, stmt.getInlineViewDef(), 
ctx.getSessionVariable().getSqlMode(),
-                stmt.getColumns(), stmt.getComment());
-    }
-
     private void modifyViewDef(Database db, View view, String inlineViewDef, 
long sqlMode,
                                List<Column> newFullSchema, String comment) 
throws DdlException {
         db.writeLockOrDdlException();
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/analysis/AlterViewStmt.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/AlterViewStmt.java
deleted file mode 100644
index 29d957cf18a..00000000000
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/AlterViewStmt.java
+++ /dev/null
@@ -1,74 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package org.apache.doris.analysis;
-
-import org.apache.doris.catalog.Column;
-import org.apache.doris.common.UserException;
-
-import java.util.List;
-
-// Alter view statement
-@Deprecated
-public class AlterViewStmt extends BaseViewStmt implements NotFallbackInParser 
{
-
-    private final String comment;
-
-    public AlterViewStmt(TableName tbl, String comment) {
-        this(tbl, null, comment);
-    }
-
-    public AlterViewStmt(TableName tbl, List<ColWithComment> cols, String 
comment) {
-        super(tbl, cols);
-        this.comment = comment;
-    }
-
-    public TableName getTbl() {
-        return tableName;
-    }
-
-    public String getComment() {
-        return comment;
-    }
-
-    @Override
-    public void analyze(Analyzer analyzer) throws UserException {
-    }
-
-    public void setInlineViewDef(String querySql) {
-        inlineViewDef = querySql;
-    }
-
-    public void setFinalColumns(List<Column> columns) {
-        finalCols.addAll(columns);
-    }
-
-    @Override
-    public String toSql() {
-        return "";
-    }
-
-    @Override
-    public String toString() {
-        return toSql();
-    }
-
-    @Override
-    public StmtType stmtType() {
-        return StmtType.ALTER;
-    }
-}
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateViewStmt.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateViewStmt.java
deleted file mode 100644
index 78ad579b225..00000000000
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateViewStmt.java
+++ /dev/null
@@ -1,73 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package org.apache.doris.analysis;
-
-import org.apache.doris.catalog.Column;
-import org.apache.doris.common.UserException;
-
-import com.google.common.base.Strings;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-
-import java.util.List;
-
-@Deprecated
-public class CreateViewStmt extends BaseViewStmt implements 
NotFallbackInParser {
-    private static final Logger LOG = 
LogManager.getLogger(CreateViewStmt.class);
-
-    private final boolean ifNotExists;
-    private final boolean orReplace;
-    private final String comment;
-
-    public CreateViewStmt(boolean ifNotExists, boolean orReplace, TableName 
tableName, List<ColWithComment> cols,
-            String comment) {
-        super(tableName, cols);
-        this.ifNotExists = ifNotExists;
-        this.orReplace = orReplace;
-        this.comment = Strings.nullToEmpty(comment);
-    }
-
-    public boolean isSetIfNotExists() {
-        return ifNotExists;
-    }
-
-    public boolean isSetOrReplace() {
-        return orReplace;
-    }
-
-    public String getComment() {
-        return comment;
-    }
-
-    @Override
-    public void analyze(Analyzer analyzer) throws UserException {
-    }
-
-    public void setInlineViewDef(String querySql) {
-        inlineViewDef = querySql;
-    }
-
-    public void setFinalColumns(List<Column> columns) {
-        finalCols.addAll(columns);
-    }
-
-    @Override
-    public StmtType stmtType() {
-        return StmtType.CREATE;
-    }
-}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java 
b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
index 09cd1bfb191..fd014114f4b 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
@@ -29,14 +29,12 @@ import org.apache.doris.analysis.AddPartitionLikeClause;
 import org.apache.doris.analysis.AdminSetPartitionVersionStmt;
 import org.apache.doris.analysis.AlterMultiPartitionClause;
 import org.apache.doris.analysis.AlterTableStmt;
-import org.apache.doris.analysis.AlterViewStmt;
 import org.apache.doris.analysis.ColumnRenameClause;
 import org.apache.doris.analysis.CreateDbStmt;
 import org.apache.doris.analysis.CreateFunctionStmt;
 import org.apache.doris.analysis.CreateMaterializedViewStmt;
 import org.apache.doris.analysis.CreateTableLikeStmt;
 import org.apache.doris.analysis.CreateTableStmt;
-import org.apache.doris.analysis.CreateViewStmt;
 import org.apache.doris.analysis.DdlStmt;
 import org.apache.doris.analysis.DistributionDesc;
 import org.apache.doris.analysis.DropDbStmt;
@@ -4951,13 +4949,6 @@ public class Env {
         this.alter.processAlterView(command, ConnectContext.get());
     }
 
-    /**
-     * used for handling AlterViewStmt (the ALTER VIEW command).
-     */
-    public void alterView(AlterViewStmt stmt) throws UserException {
-        this.alter.processAlterView(stmt, ConnectContext.get());
-    }
-
     public void createMaterializedView(CreateMaterializedViewStmt stmt)
             throws AnalysisException, DdlException, MetaNotFoundException {
         this.alter.processCreateMaterializedView(stmt);
@@ -5926,54 +5917,6 @@ public class Env {
         }
     }
 
-    public void createView(CreateViewStmt stmt) throws DdlException {
-        String dbName = stmt.getDbName();
-        String tableName = stmt.getTable();
-
-        // check if db exists
-        Database db = getInternalCatalog().getDbOrDdlException(dbName);
-
-        // check if table exists in db
-        boolean replace = false;
-        if (db.getTable(tableName).isPresent()) {
-            if (stmt.isSetIfNotExists()) {
-                LOG.info("create view[{}] which already exists", tableName);
-                return;
-            } else if (stmt.isSetOrReplace()) {
-                replace = true;
-                LOG.info("view[{}] already exists, need to replace it", 
tableName);
-            } else {
-                
ErrorReport.reportDdlException(ErrorCode.ERR_TABLE_EXISTS_ERROR, tableName);
-            }
-        }
-
-        if (replace) {
-            String comment = stmt.getComment();
-            comment = comment == null || comment.isEmpty() ? null : comment;
-            AlterViewStmt alterViewStmt = new 
AlterViewStmt(stmt.getTableName(), stmt.getColWithComments(), comment);
-            alterViewStmt.setInlineViewDef(stmt.getInlineViewDef());
-            alterViewStmt.setFinalColumns(stmt.getColumns());
-            try {
-                alterView(alterViewStmt);
-            } catch (UserException e) {
-                throw new DdlException("failed to replace view[" + tableName + 
"], reason=" + e.getMessage());
-            }
-            LOG.info("successfully replace view[{}]", tableName);
-        } else {
-            List<Column> columns = stmt.getColumns();
-
-            long tableId = Env.getCurrentEnv().getNextId();
-            View newView = new View(tableId, tableName, columns);
-            newView.setComment(stmt.getComment());
-            newView.setInlineViewDefWithSqlMode(stmt.getInlineViewDef(),
-                    ConnectContext.get().getSessionVariable().getSqlMode());
-            if (!((Database) db).createTableWithLock(newView, false, 
stmt.isSetIfNotExists()).first) {
-                throw new DdlException("Failed to create view[" + tableName + 
"].");
-            }
-            LOG.info("successfully create view[" + tableName + "-" + 
newView.getId() + "]");
-        }
-    }
-
     public FunctionRegistry getFunctionRegistry() {
         return functionRegistry;
     }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/catalog/MysqlCompatibleDatabase.java
 
b/fe/fe-core/src/main/java/org/apache/doris/catalog/MysqlCompatibleDatabase.java
index 1ce2b1222bc..75c76e72465 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/catalog/MysqlCompatibleDatabase.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/catalog/MysqlCompatibleDatabase.java
@@ -17,8 +17,8 @@
 
 package org.apache.doris.catalog;
 
-import org.apache.doris.analysis.CreateViewStmt;
 import org.apache.doris.common.Pair;
+import org.apache.doris.nereids.trees.plans.commands.CreateViewCommand;
 
 import java.io.DataOutput;
 import java.io.IOException;
@@ -51,7 +51,7 @@ public abstract class MysqlCompatibleDatabase extends 
Database {
     }
 
     /**
-     * This method must be re-implemented since {@link 
Env#createView(CreateViewStmt)}
+     * This method must be re-implemented since {@link 
Env#createView(CreateViewCommand)}
      * will call this method. And create view should not succeed under this 
database.
      */
     @Override
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/AlterViewInfo.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/AlterViewInfo.java
index 531060cf7b5..cf1e6911401 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/AlterViewInfo.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/AlterViewInfo.java
@@ -61,7 +61,7 @@ public class AlterViewInfo extends BaseViewInfo {
         viewName.analyze(ctx);
         FeNameFormat.checkTableName(viewName.getTbl());
         // disallow external catalog
-        Util.prohibitExternalCatalog(viewName.getCtl(), "AlterViewStmt");
+        Util.prohibitExternalCatalog(viewName.getCtl(), "AlterViewCommand");
 
         DatabaseIf db = 
Env.getCurrentInternalCatalog().getDbOrAnalysisException(viewName.getDb());
         TableIf table = db.getTableOrAnalysisException(viewName.getTbl());
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/CreateViewInfo.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/CreateViewInfo.java
index 713b6f047b4..af74e9fed32 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/CreateViewInfo.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/CreateViewInfo.java
@@ -57,7 +57,7 @@ public class CreateViewInfo extends BaseViewInfo {
         viewName.analyze(ctx);
         FeNameFormat.checkTableName(viewName.getTbl());
         // disallow external catalog
-        Util.prohibitExternalCatalog(viewName.getCtl(), "CreateViewStmt");
+        Util.prohibitExternalCatalog(viewName.getCtl(), "CreateViewCommand");
         // check privilege
         if (!Env.getCurrentEnv().getAccessManager().checkTblPriv(ctx, new 
TableName(viewName.getCtl(), viewName.getDb(),
                 viewName.getTbl()), PrivPredicate.CREATE)) {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/DdlExecutor.java 
b/fe/fe-core/src/main/java/org/apache/doris/qe/DdlExecutor.java
index daa5f80e975..730c8a4b1e8 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/DdlExecutor.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/DdlExecutor.java
@@ -24,7 +24,6 @@ import org.apache.doris.analysis.AlterRepositoryStmt;
 import org.apache.doris.analysis.AlterRoleStmt;
 import org.apache.doris.analysis.AlterSqlBlockRuleStmt;
 import org.apache.doris.analysis.AlterTableStmt;
-import org.apache.doris.analysis.AlterViewStmt;
 import org.apache.doris.analysis.AlterWorkloadGroupStmt;
 import org.apache.doris.analysis.AlterWorkloadSchedPolicyStmt;
 import org.apache.doris.analysis.CancelExportStmt;
@@ -42,7 +41,6 @@ import org.apache.doris.analysis.CreateMaterializedViewStmt;
 import org.apache.doris.analysis.CreateRoutineLoadStmt;
 import org.apache.doris.analysis.CreateSqlBlockRuleStmt;
 import org.apache.doris.analysis.CreateTableStmt;
-import org.apache.doris.analysis.CreateViewStmt;
 import org.apache.doris.analysis.CreateWorkloadSchedPolicyStmt;
 import org.apache.doris.analysis.DdlStmt;
 import org.apache.doris.analysis.DropCatalogStmt;
@@ -118,8 +116,6 @@ public class DdlExecutor {
             env.createMaterializedView((CreateMaterializedViewStmt) ddlStmt);
         } else if (ddlStmt instanceof AlterTableStmt) {
             env.alterTable((AlterTableStmt) ddlStmt);
-        } else if (ddlStmt instanceof AlterViewStmt) {
-            env.alterView((AlterViewStmt) ddlStmt);
         } else if (ddlStmt instanceof CancelExportStmt) {
             env.getExportMgr().cancelExportJob((CancelExportStmt) ddlStmt);
         } else if (ddlStmt instanceof CancelLoadStmt) {
@@ -165,8 +161,6 @@ public class DdlExecutor {
             env.recoverTable((RecoverTableStmt) ddlStmt);
         } else if (ddlStmt instanceof RecoverPartitionStmt) {
             env.recoverPartition((RecoverPartitionStmt) ddlStmt);
-        } else if (ddlStmt instanceof CreateViewStmt) {
-            env.createView((CreateViewStmt) ddlStmt);
         } else if (ddlStmt instanceof DropRepositoryStmt) {
             env.getBackupHandler().dropRepository((DropRepositoryStmt) 
ddlStmt);
         } else if (ddlStmt instanceof SyncStmt) {


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

Reply via email to