This is an automated email from the ASF dual-hosted git repository. panxiaolei 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 9ef26181478 [Bug](materialized-view) only throw 'MV same with base table is useless' when addMVClause's Ke… (#41144) 9ef26181478 is described below commit 9ef261814785a36aeb9c3f890d35ea49ad698d31 Author: Pxl <pxl...@qq.com> AuthorDate: Tue Sep 24 14:32:15 2024 +0800 [Bug](materialized-view) only throw 'MV same with base table is useless' when addMVClause's Ke… (#41144) …ysType same with olapTable ## Proposed changes only throw 'MV same with base table is useless' when addMVClause's KeysType same with olapTable --- .../doris/alter/MaterializedViewHandler.java | 3 +- .../mv_p0/test_duplicate_mv/test_duplicate_mv.out | 10 +++++ .../test_duplicate_mv/test_duplicate_mv.groovy | 48 ++++++++++++++++++++++ 3 files changed, 60 insertions(+), 1 deletion(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/alter/MaterializedViewHandler.java b/fe/fe-core/src/main/java/org/apache/doris/alter/MaterializedViewHandler.java index e13f4d59093..3f07be456d8 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/alter/MaterializedViewHandler.java +++ b/fe/fe-core/src/main/java/org/apache/doris/alter/MaterializedViewHandler.java @@ -601,7 +601,8 @@ public class MaterializedViewHandler extends AlterHandler { } } - if (newMVColumns.size() == olapTable.getBaseSchema().size() && !addMVClause.isReplay()) { + if (newMVColumns.size() == olapTable.getBaseSchema().size() && !addMVClause.isReplay() + && addMVClause.getMVKeysType() == olapTable.getKeysType()) { boolean allKeysMatch = true; for (int i = 0; i < newMVColumns.size(); i++) { if (!CreateMaterializedViewStmt.mvColumnBreaker(newMVColumns.get(i).getName()) diff --git a/regression-test/data/mv_p0/test_duplicate_mv/test_duplicate_mv.out b/regression-test/data/mv_p0/test_duplicate_mv/test_duplicate_mv.out new file mode 100644 index 00000000000..3b76c58f07d --- /dev/null +++ b/regression-test/data/mv_p0/test_duplicate_mv/test_duplicate_mv.out @@ -0,0 +1,10 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select_star -- +1 2 3 4 +1 2 3 4 +2 3 4 5 + +-- !select_mv1 -- +2 3 4 5 +1 2 3 4 + diff --git a/regression-test/suites/mv_p0/test_duplicate_mv/test_duplicate_mv.groovy b/regression-test/suites/mv_p0/test_duplicate_mv/test_duplicate_mv.groovy new file mode 100644 index 00000000000..5cc71669fb6 --- /dev/null +++ b/regression-test/suites/mv_p0/test_duplicate_mv/test_duplicate_mv.groovy @@ -0,0 +1,48 @@ +// 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_duplicate_mv") { + sql """ DROP TABLE IF EXISTS duplicate_table; """ + + sql """ + create table duplicate_table( + k1 int null, + k2 int null, + k3 bigint null, + k4 bigint null + ) + duplicate key (k1,k2,k3,k4) + distributed BY hash(k4) buckets 3 + properties("replication_num" = "1"); + """ + + sql "insert into duplicate_table select 1,2,3,4;" + + createMV("create materialized view deduplicate as select k1, k2, k3, k4 from duplicate_table group by k1, k2, k3, k4;") + + sql "insert into duplicate_table select 2,3,4,5;" + sql "insert into duplicate_table select 1,2,3,4;" + + qt_select_star "select * from duplicate_table order by k1;" + + mv_rewrite_success("select k1, k2, k3, k4 from duplicate_table group by k1, k2, k3, k4;", "deduplicate") + + qt_select_mv1 "select k1, k2, k3, k4 from duplicate_table group by k1, k2, k3, k4;" + +} \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org