This is an automated email from the ASF dual-hosted git repository. morrysnow pushed a commit to branch 3.1_temp_4 in repository https://gitbox.apache.org/repos/asf/doris.git
commit 794a17dbbffb37eabe72ebf01ad71f98e41a582d Author: morrySnow <[email protected]> AuthorDate: Thu Sep 4 19:23:18 2025 +0800 branch-3.1: [opt](temp_table) add drop temp table and let AS be optional in ctas #55657 picked from #55657 --- fe/.idea/vcs.xml | 20 +++------------ .../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 + 20 files changed, 72 insertions(+), 45 deletions(-) diff --git a/fe/.idea/vcs.xml b/fe/.idea/vcs.xml index dc3fa65f524..8c0f59e92e6 100644 --- a/fe/.idea/vcs.xml +++ b/fe/.idea/vcs.xml @@ -1,20 +1,4 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- - 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. - --> <project version="4"> <component name="IssueNavigationConfiguration"> <option name="links"> @@ -27,6 +11,8 @@ </option> </component> <component name="VcsDirectoryMappings"> - <mapping directory="$PROJECT_DIR$/.." vcs="Git" /> + <mapping directory="$PROJECT_DIR$/.." vcs="Git" /> + <mapping directory="$PROJECT_DIR$/../be/src/apache-orc" vcs="Git" /> + <mapping directory="$PROJECT_DIR$/../be/src/clucene" vcs="Git" /> </component> </project> \ No newline at end of file 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 3b057edab91..619b573852a 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 @@ -883,7 +883,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); @@ -959,6 +959,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..7d0d55b478a 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,6 +32,9 @@ 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.CreateMTMVCommand; +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; @@ -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(CreateMTMVCommand.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]
