This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch branch-2.1 in repository https://gitbox.apache.org/repos/asf/doris.git
commit 87c90094a7fed6ac32ae3187056f19051378f15a Author: Pxl <pxl...@qq.com> AuthorDate: Tue May 28 11:29:16 2024 +0800 [Bug](materialized-view) fix unmatch mv coz table name (#35444) fix unmatch mv coz table name --- .../doris/analysis/CreateMaterializedViewStmt.java | 1 + .../data/mv_p0/test_tbl_name/test_tbl_name.out | 9 +++ .../mv_p0/test_tbl_name/test_tbl_name.groovy | 71 ++++++++++++++++++++++ 3 files changed, 81 insertions(+) diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateMaterializedViewStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateMaterializedViewStmt.java index 5989141e3c6..ace179410d1 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateMaterializedViewStmt.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateMaterializedViewStmt.java @@ -272,6 +272,7 @@ public class CreateMaterializedViewStmt extends DdlStmt { SelectListItem selectListItem = selectList.getItems().get(i); Expr selectListItemExpr = selectListItem.getExpr(); + selectListItemExpr.setDisableTableName(true); if (!(selectListItemExpr instanceof SlotRef) && !(selectListItemExpr instanceof FunctionCallExpr) && !(selectListItemExpr instanceof ArithmeticExpr)) { throw new AnalysisException("The materialized view only support the single column or function expr. " diff --git a/regression-test/data/mv_p0/test_tbl_name/test_tbl_name.out b/regression-test/data/mv_p0/test_tbl_name/test_tbl_name.out new file mode 100644 index 00000000000..bf7db47a036 --- /dev/null +++ b/regression-test/data/mv_p0/test_tbl_name/test_tbl_name.out @@ -0,0 +1,9 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select_mv -- +141 18 +143 18 + +-- !select_mv -- +141 18 +143 18 + diff --git a/regression-test/suites/mv_p0/test_tbl_name/test_tbl_name.groovy b/regression-test/suites/mv_p0/test_tbl_name/test_tbl_name.groovy new file mode 100644 index 00000000000..30b2a402065 --- /dev/null +++ b/regression-test/suites/mv_p0/test_tbl_name/test_tbl_name.groovy @@ -0,0 +1,71 @@ +// 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. + +import org.codehaus.groovy.runtime.IOGroovyMethods + +suite ("test_tbl_name") { + + sql """drop table if exists functionality_olap;""" + + sql """ + create table functionality_olap( + id int, + type varchar(20), + score int + )DUPLICATE KEY(id) + DISTRIBUTED BY HASH(id) BUCKETS 1 + PROPERTIES ( + "replication_num" = "1" + ); + """ + + sql """insert into functionality_olap values(141,'mv',18);""" + + createMV ("""CREATE MATERIALIZED VIEW MV_OLAP_SUM as select functionality_olap.id as id, sum(functionality_olap.score) as score_max from functionality_olap group by functionality_olap.id;""") + + sql """insert into functionality_olap values(143,'mv',18);""" + + explain { + sql("""select + functionality_olap.id as id, + sum(functionality_olap.score) as score_max + from functionality_olap + group by functionality_olap.id order by 1,2; """) + contains "(MV_OLAP_SUM)" + } + qt_select_mv """select + functionality_olap.id as id, + sum(functionality_olap.score) as score_max + from functionality_olap + group by functionality_olap.id order by 1,2;""" + + explain { + sql("""select + id, + sum(score) as score_max + from functionality_olap + group by id order by 1,2; + """) + contains "(MV_OLAP_SUM)" + } + qt_select_mv """select + id, + sum(score) as score_max + from functionality_olap + group by id order by 1,2; + """ +} --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org