This is an automated email from the ASF dual-hosted git repository. morrysnow pushed a commit to branch 2.0.1-rc04-patch in repository https://gitbox.apache.org/repos/asf/doris.git
commit 2bede8d978be2270766da7c25dbb3d1ec0ba58e3 Author: starocean999 <40539150+starocean...@users.noreply.github.com> AuthorDate: Sat Sep 9 20:55:09 2023 +0800 [fix](planner)ctas's query part is not analyzed correctly (#24111) * [fix](planner)ctas's query part is not analyzed correctly --- .../doris/analysis/CreateTableAsSelectStmt.java | 6 ++ .../java/org/apache/doris/analysis/QueryStmt.java | 1 + .../java/org/apache/doris/qe/StmtExecutor.java | 4 + .../data/correctness_p0/test_ctas_mv.out | 4 + .../suites/correctness_p0/test_ctas_mv.groovy | 104 +++++++++++++++++++++ 5 files changed, 119 insertions(+) diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateTableAsSelectStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateTableAsSelectStmt.java index d9e507445e..0db7bb93c1 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateTableAsSelectStmt.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateTableAsSelectStmt.java @@ -108,4 +108,10 @@ public class CreateTableAsSelectStmt extends DdlStmt { ErrorReport.reportAnalysisException(ErrorCode.ERR_COL_NUMBER_NOT_MATCH); } } + + @Override + public void reset() { + super.reset(); + queryStmt.reset(); + } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/QueryStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/QueryStmt.java index b3f2458207..c705fc5ea9 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/QueryStmt.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/QueryStmt.java @@ -785,6 +785,7 @@ public abstract class QueryStmt extends StatementBase implements Queriable { sortInfo = (other.sortInfo != null) ? other.sortInfo.clone() : null; analyzer = other.analyzer; evaluateOrderBy = other.evaluateOrderBy; + disableTuplesMVRewriter = other.disableTuplesMVRewriter; } @Override 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 6da5c07c30..74adf14f5c 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 @@ -1149,6 +1149,10 @@ public class StmtExecutor { if (parsedStmt instanceof InsertStmt) { ((InsertStmt) parsedStmt).getQueryStmt().resetSelectList(); } + + if (parsedStmt instanceof CreateTableAsSelectStmt) { + ((CreateTableAsSelectStmt) parsedStmt).getQueryStmt().resetSelectList(); + } } // Because this is called by other thread diff --git a/regression-test/data/correctness_p0/test_ctas_mv.out b/regression-test/data/correctness_p0/test_ctas_mv.out new file mode 100644 index 0000000000..4c6862e6be --- /dev/null +++ b/regression-test/data/correctness_p0/test_ctas_mv.out @@ -0,0 +1,4 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select -- + 123 202301 20230131 \N + diff --git a/regression-test/suites/correctness_p0/test_ctas_mv.groovy b/regression-test/suites/correctness_p0/test_ctas_mv.groovy new file mode 100644 index 0000000000..d3fc00a0a9 --- /dev/null +++ b/regression-test/suites/correctness_p0/test_ctas_mv.groovy @@ -0,0 +1,104 @@ +// 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. + +suite("test_ctas_mv") { + sql """set enable_nereids_planner=false;""" + sql """ + drop table if exists test_table_t1; + """ + + sql """ + drop table if exists test_table_t2; + """ + + sql """ + drop table if exists szjdf_zjb; + """ + + sql """ + CREATE TABLE test_table_t1 ( + a1 varchar(65533) NULL default '123', + a2 varchar(64) NULL default '', + a3 varchar(65533) NULL default '', + a4 varchar(65533) NULL default '', + a5 varchar(64) default '2023-01-31', + a6 varchar(64) default '' + ) ENGINE = OLAP + DUPLICATE KEY(a1) + DISTRIBUTED BY HASH(a1) BUCKETS 3 + PROPERTIES ( + "replication_allocation"="tag.location.default:1", + "is_being_synced"="false", + "storage_format"="V2", + "disable_auto_compaction"="false", + "enable_single_replica_compaction"="false" + ); + """ + + sql """ + CREATE TABLE test_table_t2 ( + a1 varchar(64) NULL default '123' + ) ENGINE = OLAP + DUPLICATE KEY(a1) + DISTRIBUTED BY HASH(a1) BUCKETS AUTO + PROPERTIES ( + "replication_allocation"="tag.location.default:1", + "is_being_synced"="false", + "storage_format"="V2", + "disable_auto_compaction"="false", + "enable_single_replica_compaction"="false" + ); + """ + + sql """ insert into test_table_t1 values(); """ + sql """ insert into test_table_t2 values(); """ + + sql """ CREATE MATERIALIZED VIEW test_table_view As + select a1,a3,a4,DATE_FORMAT(a5, 'yyyyMMdd') QUERY_TIME,DATE_FORMAT(a6 ,'yyyyMMdd') CREATE_TIME + from test_table_t1 where DATE_FORMAT(a5, 'yyyyMMdd') =20230131; """ + + sql """ create table szjdf_zjb PROPERTIES("replication_num"="1") as + select disf.a2, disf.a1, disf.a3, disf.a4, + substr(date_format(disf.a5,"yyyyMMdd"), 1, 6), + date_format(disf.a5,"yyyyMMdd"), + date_format(disf.a6,"yyyyMMdd") + from + ( + select * from test_table_t1 + where date_format(a5,"yyyyMMdd") >=20230131 and date_format(a5,"yyyyMMdd") <=20230131 + and a3 is not NULL + ) disf + left join + test_table_t2 cmif + on disf.a1 = cmif.a1; """ + + qt_select """ + select * from szjdf_zjb; + """ + + sql """ + drop table if exists test_table_t1 FORCE; + """ + + sql """ + drop table if exists test_table_t2; + """ + + sql """ + drop table if exists szjdf_zjb; + """ +} --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org