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
The following commit(s) were added to refs/heads/branch-2.1 by this push: new d1fc4e2e607 [Bug](query) fix meet invalid column when direct scan on mow mv (#37806) d1fc4e2e607 is described below commit d1fc4e2e607cf8179f0fbe03b6105a8c868e5498 Author: Pxl <pxl...@qq.com> AuthorDate: Mon Jul 15 18:29:30 2024 +0800 [Bug](query) fix meet invalid column when direct scan on mow mv (#37806) pick from #36483 --- .../doris/nereids/rules/analysis/BindRelation.java | 10 ++--- .../data/mv_p0/test_mv_mor/test_mv_mor.out | 17 +++++++ .../suites/mv_p0/test_mv_mor/test_mv_mor.groovy | 52 ++++++++++++++++++++++ 3 files changed, 72 insertions(+), 7 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindRelation.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindRelation.java index b76fe7c07ea..e6f550305e3 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindRelation.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindRelation.java @@ -18,7 +18,6 @@ package org.apache.doris.nereids.rules.analysis; import org.apache.doris.catalog.Column; -import org.apache.doris.catalog.KeysType; import org.apache.doris.catalog.OlapTable; import org.apache.doris.catalog.Partition; import org.apache.doris.catalog.TableIf; @@ -202,10 +201,8 @@ public class BindRelation extends OneAnalysisRuleFactory { throw new AnalysisException("Table " + olapTable.getName() + " doesn't have materialized view " + indexName.get()); } - PreAggStatus preAggStatus - = olapTable.getIndexMetaByIndexId(indexId).getKeysType().equals(KeysType.DUP_KEYS) - ? PreAggStatus.unset() - : PreAggStatus.off("For direct index scan."); + PreAggStatus preAggStatus = olapTable.isDupKeysOrMergeOnWrite() ? PreAggStatus.unset() + : PreAggStatus.off("For direct index scan on mor/agg."); scan = new LogicalOlapScan(unboundRelation.getRelationId(), (OlapTable) table, qualifier, tabletIds, @@ -219,8 +216,7 @@ public class BindRelation extends OneAnalysisRuleFactory { } } if (!Util.showHiddenColumns() && scan.getTable().hasDeleteSign() - && !ConnectContext.get().getSessionVariable().skipDeleteSign() - && !scan.isDirectMvScan()) { + && !ConnectContext.get().getSessionVariable().skipDeleteSign()) { // table qualifier is catalog.db.table, we make db.table.column Slot deleteSlot = null; for (Slot slot : scan.getOutput()) { diff --git a/regression-test/data/mv_p0/test_mv_mor/test_mv_mor.out b/regression-test/data/mv_p0/test_mv_mor/test_mv_mor.out new file mode 100644 index 00000000000..fbf59000daf --- /dev/null +++ b/regression-test/data/mv_p0/test_mv_mor/test_mv_mor.out @@ -0,0 +1,17 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select_mv -- +1 2 +1 3 + +-- !select_mv -- +1 2 +1 3 + +-- !select_mv -- +1 +1 + +-- !select_mv -- +2 +3 + diff --git a/regression-test/suites/mv_p0/test_mv_mor/test_mv_mor.groovy b/regression-test/suites/mv_p0/test_mv_mor/test_mv_mor.groovy new file mode 100644 index 00000000000..1ca52c75e86 --- /dev/null +++ b/regression-test/suites/mv_p0/test_mv_mor/test_mv_mor.groovy @@ -0,0 +1,52 @@ +// 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_mv_mor") { + sql """ drop table if exists u_table; """ + + sql """ + create table u_table ( + k1 int null, + k2 int not null, + k3 bigint null, + k4 varchar(100) null + ) + unique key (k1,k2,k3) + distributed BY hash(k1) buckets 3 + properties( + "replication_num" = "1", + "enable_unique_key_merge_on_write" = "false" + ); + """ + sql "insert into u_table select 1,1,1,1;" + sql "insert into u_table select 1,2,1,1;" + createMV("create materialized view k123p as select k1,k2+k3 from u_table;") + + sql "insert into u_table select 1,1,1,2;" + sql "insert into u_table select 1,2,1,2;" + + // do not match mv coz preagg is off, mv need contains all key column to make row count correct + explain { + sql("select k1,k2+k3 from u_table order by k1;") + contains "(u_table)" + } + qt_select_mv "select k1,k2+k3 from u_table order by k1;" + + qt_select_mv "select * from `u_table` index `k123p` order by 1,2;" + qt_select_mv "select mv_k1 from `u_table` index `k123p` order by 1;" + qt_select_mv "select `mv_(k2 + k3)` from `u_table` index `k123p` order by 1;" +} --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org