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

morrysnow pushed a commit to branch branch-3.1
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-3.1 by this push:
     new f438cd95069 branch-3.1: [opt](temp_table) add drop temp table and let 
AS be optional in ctas #55657 (#55726)
f438cd95069 is described below

commit f438cd95069f3da9de6d45c94021a5cf11bc0b0a
Author: morrySnow <[email protected]>
AuthorDate: Mon Sep 8 18:06:23 2025 +0800

    branch-3.1: [opt](temp_table) add drop temp table and let AS be optional in 
ctas #55657 (#55726)
    
    picked from #55657
---
 .../antlr4/org/apache/doris/nereids/DorisParser.g4 |  6 ++---
 fe/fe-core/src/main/cup/sql_parser.cup             |  6 ++---
 .../org/apache/doris/analysis/DropTableStmt.java   | 14 ++++++++---
 .../main/java/org/apache/doris/catalog/Env.java    |  2 +-
 .../doris/catalog/InternalSchemaInitializer.java   |  2 +-
 .../org/apache/doris/datasource/CatalogIf.java     |  2 +-
 .../apache/doris/datasource/ExternalCatalog.java   |  2 +-
 .../apache/doris/datasource/InternalCatalog.java   |  5 +++-
 .../iceberg/IcebergDLFExternalCatalog.java         |  2 +-
 .../doris/nereids/parser/LogicalPlanBuilder.java   |  4 +--
 .../trees/plans/commands/CreateTableCommand.java   |  2 +-
 .../trees/plans/commands/info/DropMTMVInfo.java    |  2 +-
 .../java/org/apache/doris/qe/StmtExecutor.java     |  4 +--
 .../apache/doris/analysis/DropTableStmtTest.java   |  8 +++---
 .../doris/catalog/DropMaterializedViewTest.java    |  2 +-
 .../dlf/client/IcebergDLFExternalCatalogTest.java  |  2 +-
 .../doris/nereids/parser/NereidsParserTest.java    | 29 ++++++++++++++++++++++
 regression-test/ctas_p0/ctas_aggregate_t1.groovy   |  2 +-
 .../suites/temp_table_p0/test_temp_table.groovy    |  1 +
 19 files changed, 69 insertions(+), 28 deletions(-)

diff --git a/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4 
b/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4
index 9c51a8a353d..1c2c5e52e98 100644
--- a/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4
+++ b/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4
@@ -97,7 +97,7 @@ materializedViewStatement
         (DISTRIBUTED BY (HASH hashKeys=identifierList | RANDOM)
         (BUCKETS (INTEGER_VALUE | AUTO))?)?
         propertyClause?
-        AS query                                                               
                 #createMTMV
+        AS? query                                                              
                 #createMTMV
     | REFRESH MATERIALIZED VIEW mvName=multipartIdentifier (partitionSpec | 
COMPLETE | AUTO)    #refreshMTMV
     | ALTER MATERIALIZED VIEW mvName=multipartIdentifier ((RENAME 
newName=identifier)
         | (REFRESH (refreshMethod | refreshTrigger | refreshMethod 
refreshTrigger))
@@ -176,10 +176,10 @@ supportedCreateStatement
         (ROLLUP LEFT_PAREN rollupDefs RIGHT_PAREN)?
         properties=propertyClause?
         (BROKER extProperties=propertyClause)?
-        (AS query)?                                                       
#createTable
+        (AS? query)?                                                      
#createTable
     | CREATE (OR REPLACE)? VIEW (IF NOT EXISTS)? name=multipartIdentifier
         (LEFT_PAREN cols=simpleColumnDefs RIGHT_PAREN)?
-        (COMMENT STRING_LITERAL)? AS query                                
#createView
+        (COMMENT STRING_LITERAL)? AS? query                               
#createView
     | CREATE (EXTERNAL | TEMPORARY)? TABLE (IF NOT EXISTS)? 
name=multipartIdentifier
         LIKE existedTable=multipartIdentifier
         (WITH ROLLUP (rollupNames=identifierList)?)?                      
#createTableLike
diff --git a/fe/fe-core/src/main/cup/sql_parser.cup 
b/fe/fe-core/src/main/cup/sql_parser.cup
index 71dad66d795..4ee2eedbb11 100644
--- a/fe/fe-core/src/main/cup/sql_parser.cup
+++ b/fe/fe-core/src/main/cup/sql_parser.cup
@@ -3316,9 +3316,9 @@ drop_stmt ::=
         RESULT = new DropFunctionStmt(type, ifExists, functionName, args);
     :}
     /* Table */
-    | KW_DROP KW_TABLE opt_if_exists:ifExists table_name:name opt_force:force
+    | KW_DROP opt_tmp:tmp KW_TABLE opt_if_exists:ifExists table_name:name 
opt_force:force
     {:
-        RESULT = new DropTableStmt(ifExists, name, force);
+        RESULT = new DropTableStmt(ifExists, tmp, name, force);
     :}
     /* User */
     | KW_DROP KW_USER opt_if_exists:ifExists user_identity:userId
@@ -3328,7 +3328,7 @@ drop_stmt ::=
     /* View */
     | KW_DROP KW_VIEW opt_if_exists:ifExists table_name:name
     {:
-        RESULT = new DropTableStmt(ifExists, name, true, false);
+        RESULT = new DropTableStmt(ifExists, false, name, true, false);
     :}
     | KW_DROP KW_REPOSITORY ident:repoName
     {:
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/analysis/DropTableStmt.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/DropTableStmt.java
index d6a19e81f8e..8f16ce77475 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/DropTableStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/DropTableStmt.java
@@ -31,19 +31,23 @@ import com.google.common.base.Strings;
 public class DropTableStmt extends DdlStmt implements NotFallbackInParser {
     private boolean ifExists;
     private final TableName tableName;
+    private boolean mustTemporary;
     private final boolean isView;
     private boolean forceDrop;
     private boolean isMaterializedView;
 
-    public DropTableStmt(boolean ifExists, TableName tableName, boolean 
forceDrop) {
+    public DropTableStmt(boolean ifExists, boolean mustTemporary, TableName 
tableName, boolean forceDrop) {
         this.ifExists = ifExists;
+        this.mustTemporary = mustTemporary;
         this.tableName = tableName;
         this.isView = false;
         this.forceDrop = forceDrop;
     }
 
-    public DropTableStmt(boolean ifExists, TableName tableName, boolean 
isView, boolean forceDrop) {
+    public DropTableStmt(boolean ifExists, boolean mustTemporary,
+            TableName tableName, boolean isView, boolean forceDrop) {
         this.ifExists = ifExists;
+        this.mustTemporary = mustTemporary;
         this.tableName = tableName;
         this.isView = isView;
         this.forceDrop = forceDrop;
@@ -81,6 +85,10 @@ public class DropTableStmt extends DdlStmt implements 
NotFallbackInParser {
         return isMaterializedView;
     }
 
+    public boolean isMustTemporary() {
+        return mustTemporary;
+    }
+
     @Override
     public void analyze(Analyzer analyzer) throws UserException {
         if (Strings.isNullOrEmpty(tableName.getDb())) {
@@ -89,7 +97,7 @@ public class DropTableStmt extends DdlStmt implements 
NotFallbackInParser {
         tableName.analyze(analyzer);
         InternalDatabaseUtil.checkDatabase(tableName.getDb(), 
ConnectContext.get());
         // check access
-        if (!Env.getCurrentEnv().getAccessManager()
+        if (!mustTemporary && !Env.getCurrentEnv().getAccessManager()
                 .checkTblPriv(ConnectContext.get(), tableName.getCtl(), 
tableName.getDb(),
                         tableName.getTbl(), PrivPredicate.DROP)) {
             
ErrorReport.reportAnalysisException(ErrorCode.ERR_SPECIFIC_ACCESS_DENIED_ERROR, 
"DROP");
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 fc951dab7b9..35e2f7b0637 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
@@ -4352,7 +4352,7 @@ public class Env {
         CatalogIf<?> catalogIf = 
catalogMgr.getCatalogOrException(stmt.getCatalogName(),
                 catalog -> new DdlException(("Unknown catalog " + catalog)));
         catalogIf.dropTable(stmt.getDbName(), stmt.getTableName(), 
stmt.isView(), stmt.isMaterializedView(),
-                stmt.isSetIfExists(), stmt.isForceDrop());
+                stmt.isSetIfExists(), stmt.isMustTemporary(), 
stmt.isForceDrop());
     }
 
     public void replayDropTable(Database db, long tableId, boolean isForceDrop,
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/catalog/InternalSchemaInitializer.java
 
b/fe/fe-core/src/main/java/org/apache/doris/catalog/InternalSchemaInitializer.java
index 2d437fdc5f6..ab04e5dab19 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/catalog/InternalSchemaInitializer.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/catalog/InternalSchemaInitializer.java
@@ -348,7 +348,7 @@ public class InternalSchemaInitializer extends Thread {
             try {
                 Env.getCurrentEnv().getInternalCatalog()
                         .dropTable(StatisticConstants.DB_NAME, 
StatisticConstants.TABLE_STATISTIC_TBL_NAME,
-                                false, false, true, true);
+                                false, false, true, false, true);
             } catch (Exception e) {
                 LOG.warn("Failed to drop outdated table", e);
             }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/CatalogIf.java 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/CatalogIf.java
index e9a346a9102..4482fe6f8ae 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/CatalogIf.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/CatalogIf.java
@@ -197,7 +197,7 @@ public interface CatalogIf<T extends DatabaseIf> {
     boolean createTable(CreateTableStmt stmt) throws UserException;
 
     void dropTable(String dbName, String tableName, boolean isView, boolean 
isMtmv, boolean ifExists,
-            boolean force) throws DdlException;
+            boolean mustTemporary, boolean force) throws DdlException;
 
     default void renameTable(String dbName, String oldTableName, String 
newTableName) throws DdlException {
         throw new UnsupportedOperationException("Not support rename table 
operation");
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalCatalog.java 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalCatalog.java
index 156deefca72..5b2d85bb0a8 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalCatalog.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalCatalog.java
@@ -1158,7 +1158,7 @@ public abstract class ExternalCatalog
 
     @Override
     public void dropTable(String dbName, String tableName, boolean isView, 
boolean isMtmv, boolean ifExists,
-                          boolean force) throws DdlException {
+            boolean mustTemporary, boolean force) throws DdlException {
         makeSureInitialized();
         if (metadataOps == null) {
             throw new DdlException("Drop table is not supported for catalog: " 
+ getName());
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java
index e5c3ba5bf77..370077f67dd 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java
@@ -885,7 +885,7 @@ public class InternalCatalog implements CatalogIf<Database> 
{
 
     @Override
     public void dropTable(String dbName, String tableName, boolean isView, 
boolean isMtmv,
-            boolean ifExists, boolean force) throws DdlException {
+            boolean ifExists, boolean mustTemporary, boolean force) throws 
DdlException {
         Map<String, Long> costTimes = new TreeMap<String, Long>();
         StopWatch watch = StopWatch.createStarted();
         LOG.info("begin to drop table: {} from db: {}, is force: {}", 
tableName, dbName, force);
@@ -961,6 +961,9 @@ public class InternalCatalog implements CatalogIf<Database> 
{
             if (table.isTemporary()) {
                 dropTableInternal(db, table, false, true, watch, costTimes);
             } else {
+                if (mustTemporary) {
+                    
ErrorReport.reportDdlException(ErrorCode.ERR_UNKNOWN_TABLE, tableName, dbName);
+                }
                 dropTableInternal(db, table, isView, force, watch, costTimes);
             }
         } catch (UserException e) {
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergDLFExternalCatalog.java
 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergDLFExternalCatalog.java
index 88cda702ae1..cd9e9e62dcb 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergDLFExternalCatalog.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergDLFExternalCatalog.java
@@ -53,7 +53,7 @@ public class IcebergDLFExternalCatalog extends 
IcebergExternalCatalog {
 
     @Override
     public void dropTable(String dbName, String tableName, boolean isView, 
boolean isMtmv, boolean ifExists,
-            boolean force) throws DdlException {
+            boolean mustTemporary, boolean force) throws DdlException {
         throw new NotSupportedException("iceberg catalog with dlf type not 
supports 'drop table'");
     }
 
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
index 4b6dcf7d652..4bff83fb40f 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
@@ -2603,7 +2603,7 @@ public class LogicalPlanBuilder extends 
DorisParserBaseVisitor<Object> {
         }
 
         if (ctx.columnDefs() != null) {
-            if (ctx.AS() != null) {
+            if (ctx.query() != null) {
                 throw new AnalysisException("Should not define the entire 
column in CTAS");
             }
             return new CreateTableCommand(Optional.empty(), new 
CreateTableInfo(
@@ -2625,7 +2625,7 @@ public class LogicalPlanBuilder extends 
DorisParserBaseVisitor<Object> {
                     properties,
                     extProperties,
                     ctx.clusterKeys != null ? 
visitIdentifierList(ctx.clusterKeys) : ImmutableList.of()));
-        } else if (ctx.AS() != null) {
+        } else if (ctx.query() != null) {
             return new 
CreateTableCommand(Optional.of(visitQuery(ctx.query())), new CreateTableInfo(
                     ctx.EXISTS() != null,
                     ctx.EXTERNAL() != null,
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/CreateTableCommand.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/CreateTableCommand.java
index 66e181b38dc..3ace2194fc3 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/CreateTableCommand.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/CreateTableCommand.java
@@ -190,7 +190,7 @@ public class CreateTableCommand extends Command implements 
ForwardWithSync {
 
     void handleFallbackFailedCtas(ConnectContext ctx) {
         try {
-            Env.getCurrentEnv().dropTable(new DropTableStmt(false,
+            Env.getCurrentEnv().dropTable(new DropTableStmt(false, false,
                     new TableName(createTableInfo.getCtlName(),
                             createTableInfo.getDbName(), 
createTableInfo.getTableName()), true));
         } catch (Exception e) {
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/DropMTMVInfo.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/DropMTMVInfo.java
index 47ae57c7e49..37f11bd86dc 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/DropMTMVInfo.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/DropMTMVInfo.java
@@ -69,7 +69,7 @@ public class DropMTMVInfo {
      */
     public DropTableStmt translateToLegacyStmt() {
         TableName tableName = mvName.transferToTableName();
-        DropTableStmt dropTableStmt = new DropTableStmt(ifExists, tableName, 
true);
+        DropTableStmt dropTableStmt = new DropTableStmt(ifExists, false, 
tableName, true);
         dropTableStmt.setMaterializedView(true);
         return dropTableStmt;
     }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java 
b/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java
index 28a403c8503..ddd9ed971d4 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java
@@ -3236,7 +3236,7 @@ public class StmtExecutor {
     private void handleCtasRollback(TableName table) {
         if (context.getSessionVariable().isDropTableIfCtasFailed()) {
             // insert error drop table
-            DropTableStmt dropTableStmt = new DropTableStmt(true, table, true);
+            DropTableStmt dropTableStmt = new DropTableStmt(true, false, 
table, true);
             try {
                 DdlExecutor.execute(context.getEnv(), dropTableStmt);
             } catch (Exception ex) {
@@ -3412,7 +3412,7 @@ public class StmtExecutor {
 
     private void handleIotRollback(TableName table) {
         // insert error drop the tmp table
-        DropTableStmt dropTableStmt = new DropTableStmt(true, table, true);
+        DropTableStmt dropTableStmt = new DropTableStmt(true, false, table, 
true);
         try {
             Analyzer tempAnalyzer = new Analyzer(Env.getCurrentEnv(), context);
             dropTableStmt.analyze(tempAnalyzer);
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/analysis/DropTableStmtTest.java 
b/fe/fe-core/src/test/java/org/apache/doris/analysis/DropTableStmtTest.java
index 437e54f58f2..1eca66ba49b 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/analysis/DropTableStmtTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/analysis/DropTableStmtTest.java
@@ -68,7 +68,7 @@ public class DropTableStmtTest {
 
     @Test
     public void testNormal() throws UserException, AnalysisException {
-        DropTableStmt stmt = new DropTableStmt(false, tbl, true);
+        DropTableStmt stmt = new DropTableStmt(false, false, tbl, true);
         stmt.analyze(analyzer);
         Assert.assertEquals("db1", stmt.getDbName());
         Assert.assertEquals("table1", stmt.getTableName());
@@ -78,7 +78,7 @@ public class DropTableStmtTest {
 
     @Test
     public void testDefaultNormal() throws UserException, AnalysisException {
-        DropTableStmt stmt = new DropTableStmt(false, noDbTbl, false);
+        DropTableStmt stmt = new DropTableStmt(false, false, noDbTbl, false);
         stmt.analyze(analyzer);
         Assert.assertEquals("testDb", stmt.getDbName());
         Assert.assertEquals("table1", stmt.getTableName());
@@ -87,14 +87,14 @@ public class DropTableStmtTest {
 
     @Test(expected = AnalysisException.class)
     public void testNoDbFail() throws UserException, AnalysisException {
-        DropTableStmt stmt = new DropTableStmt(false, noDbTbl, true);
+        DropTableStmt stmt = new DropTableStmt(false, false, noDbTbl, true);
         stmt.analyze(noDbAnalyzer);
         Assert.fail("No Exception throws.");
     }
 
     @Test(expected = AnalysisException.class)
     public void testNoTableFail() throws UserException, AnalysisException {
-        DropTableStmt stmt = new DropTableStmt(false, new 
TableName(internalCtl, "db1", ""), true);
+        DropTableStmt stmt = new DropTableStmt(false, false, new 
TableName(internalCtl, "db1", ""), true);
         stmt.analyze(noDbAnalyzer);
         Assert.fail("No Exception throws.");
     }
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/catalog/DropMaterializedViewTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/catalog/DropMaterializedViewTest.java
index 2edd5380378..f47ae68c517 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/catalog/DropMaterializedViewTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/catalog/DropMaterializedViewTest.java
@@ -108,7 +108,7 @@ public class DropMaterializedViewTest {
     }
 
     private static void dropTable(String db, String tbl, boolean 
isMaterializedView) throws Exception {
-        DropTableStmt dropTableStmt = new DropTableStmt(false,
+        DropTableStmt dropTableStmt = new DropTableStmt(false, false,
                 new TableName(InternalCatalog.INTERNAL_CATALOG_NAME, db, tbl), 
false, false);
         if (isMaterializedView) {
             dropTableStmt.setMaterializedView(true);
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/datasource/iceberg/dlf/client/IcebergDLFExternalCatalogTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/datasource/iceberg/dlf/client/IcebergDLFExternalCatalogTest.java
index ae375b6e8a9..16be9727859 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/datasource/iceberg/dlf/client/IcebergDLFExternalCatalogTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/datasource/iceberg/dlf/client/IcebergDLFExternalCatalogTest.java
@@ -49,7 +49,7 @@ public class IcebergDLFExternalCatalogTest {
         Assert.assertThrows(NotSupportedException.class, () -> 
catalog.createDb("db1", true, Maps.newHashMap()));
         Assert.assertThrows(NotSupportedException.class, () -> 
catalog.dropDb("", true, true));
         Assert.assertThrows(NotSupportedException.class, () -> 
catalog.createTable(null));
-        Assert.assertThrows(NotSupportedException.class, () -> 
catalog.dropTable("", "", true, true, true, true));
+        Assert.assertThrows(NotSupportedException.class, () -> 
catalog.dropTable("", "", true, true, true, false, true));
         Assert.assertThrows(NotSupportedException.class, () -> 
catalog.truncateTable("", "", null, true, ""));
     }
 }
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/parser/NereidsParserTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/parser/NereidsParserTest.java
index b02ea73e048..6d1979092bb 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/parser/NereidsParserTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/parser/NereidsParserTest.java
@@ -32,9 +32,12 @@ import org.apache.doris.nereids.trees.plans.DistributeType;
 import org.apache.doris.nereids.trees.plans.JoinType;
 import org.apache.doris.nereids.trees.plans.Plan;
 import org.apache.doris.nereids.trees.plans.PlanType;
+import org.apache.doris.nereids.trees.plans.commands.CreateTableCommand;
+import org.apache.doris.nereids.trees.plans.commands.CreateViewCommand;
 import org.apache.doris.nereids.trees.plans.commands.ExplainCommand;
 import 
org.apache.doris.nereids.trees.plans.commands.ExplainCommand.ExplainLevel;
 import org.apache.doris.nereids.trees.plans.commands.ReplayCommand;
+import org.apache.doris.nereids.trees.plans.commands.UnsupportedCommand;
 import org.apache.doris.nereids.trees.plans.logical.LogicalAggregate;
 import org.apache.doris.nereids.trees.plans.logical.LogicalCTE;
 import org.apache.doris.nereids.trees.plans.logical.LogicalJoin;
@@ -844,4 +847,30 @@ public class NereidsParserTest extends ParserTestBase {
                 .assertThrowsExactly(ParseException.class)
                 .assertMessageContains("mismatched input '->' expecting 
{<EOF>, ';'}");
     }
+
+    @Test
+    public void testCtasWithoutAs() {
+        NereidsParser parser = new NereidsParser();
+        String sql = "CREATE TABLE t1 SELECT * FROM t2";
+        LogicalPlan logicalPlan = parser.parseSingle(sql);
+        Assertions.assertInstanceOf(CreateTableCommand.class, logicalPlan);
+        CreateTableCommand createTableCommand = (CreateTableCommand) 
logicalPlan;
+        Assertions.assertTrue(createTableCommand.getCtasQuery().isPresent());
+    }
+
+    @Test
+    public void testCreateViewWithoutAs() {
+        NereidsParser parser = new NereidsParser();
+        String sql = "CREATE VIEW t1 SELECT * FROM t2";
+        LogicalPlan logicalPlan = parser.parseSingle(sql);
+        Assertions.assertInstanceOf(CreateViewCommand.class, logicalPlan);
+    }
+
+    @Test
+    public void testCreateMvWithoutAs() {
+        NereidsParser parser = new NereidsParser();
+        String sql = "CREATE MATERIALIZED VIEW t1 SELECT * FROM t2";
+        LogicalPlan logicalPlan = parser.parseSingle(sql);
+        Assertions.assertInstanceOf(UnsupportedCommand.class, logicalPlan);
+    }
 }
diff --git a/regression-test/ctas_p0/ctas_aggregate_t1.groovy 
b/regression-test/ctas_p0/ctas_aggregate_t1.groovy
index 869acf821ad..5a001683bb0 100644
--- a/regression-test/ctas_p0/ctas_aggregate_t1.groovy
+++ b/regression-test/ctas_p0/ctas_aggregate_t1.groovy
@@ -58,7 +58,7 @@ suite("ctas_aggregate_t1") {
         PROPERTIES (
         "replication_allocation" = "tag.location.default: 1"
         ) 
-        as select * from ${tbName};
+        select * from ${tbName};
              
      """
 
diff --git a/regression-test/suites/temp_table_p0/test_temp_table.groovy 
b/regression-test/suites/temp_table_p0/test_temp_table.groovy
index b09875c96a8..4a3b8022887 100644
--- a/regression-test/suites/temp_table_p0/test_temp_table.groovy
+++ b/regression-test/suites/temp_table_p0/test_temp_table.groovy
@@ -676,6 +676,7 @@ suite('test_temp_table', 'p0') {
     // clean
     sql "use regression_test_temp_table_p0"
     sql "drop table t_test_temp_table1"
+    sql "drop temporary table t_test_temp_table6"
     sql "drop table t_test_table3_0"
     sql "drop table t_test_table_no_partition"
     sql "DROP USER IF EXISTS temp_table_test_user"


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

Reply via email to