This is an automated email from the ASF dual-hosted git repository.

morrysnow pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new f370e35d7b2 [Fix](MV) query not hit partition in original planner 
(#38565)
f370e35d7b2 is described below

commit f370e35d7b26dc4719847c05dd837b837447dd2a
Author: GoGoWen <82132356+gogo...@users.noreply.github.com>
AuthorDate: Wed Aug 14 17:36:05 2024 +0800

    [Fix](MV) query not hit partition in original planner (#38565)
    
    this issue seems introduced by #21533
    
    Fix issue that query not hit partition in original planner, which will
    cause serve performance degradation.
---
 .../doris/planner/HashDistributionPruner.java      |  8 +++-
 .../rollup_p0/test_rollup_prune_tablet.groovy      | 52 ++++++++++++++++++++++
 2 files changed, 58 insertions(+), 2 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/planner/HashDistributionPruner.java 
b/fe/fe-core/src/main/java/org/apache/doris/planner/HashDistributionPruner.java
index 2a60e4029a6..cae7ad9cd2b 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/planner/HashDistributionPruner.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/planner/HashDistributionPruner.java
@@ -24,6 +24,7 @@ import org.apache.doris.analysis.SlotRef;
 import org.apache.doris.catalog.Column;
 import org.apache.doris.catalog.PartitionKey;
 import org.apache.doris.common.Config;
+import org.apache.doris.qe.ConnectContext;
 
 import com.google.common.collect.Lists;
 import com.google.common.collect.Sets;
@@ -79,10 +80,13 @@ public class HashDistributionPruner implements 
DistributionPruner {
             return Lists.newArrayList(bucketsList.get((int) ((hashValue & 
0xffffffff) % hashMod)));
         }
         Column keyColumn = distributionColumns.get(columnId);
-        String columnName = isBaseIndexSelected ? keyColumn.getName()
-                : 
org.apache.doris.nereids.rules.rewrite.mv.AbstractSelectMaterializedIndexRule
+        String columnName = keyColumn.getName();
+        if (!isBaseIndexSelected && 
ConnectContext.get().getSessionVariable().isEnableNereidsPlanner()) {
+            columnName = 
org.apache.doris.nereids.rules.rewrite.mv.AbstractSelectMaterializedIndexRule
                         .normalizeName(
                                 
CreateMaterializedViewStmt.mvColumnBuilder(keyColumn.getName()));
+        }
+
         PartitionColumnFilter filter = 
distributionColumnFilters.get(columnName);
         if (null == filter) {
             // no filter in this column, no partition Key
diff --git a/regression-test/suites/rollup_p0/test_rollup_prune_tablet.groovy 
b/regression-test/suites/rollup_p0/test_rollup_prune_tablet.groovy
new file mode 100644
index 00000000000..7add67d059a
--- /dev/null
+++ b/regression-test/suites/rollup_p0/test_rollup_prune_tablet.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_rollup_prune_tablet") {
+    sql "SET enable_nereids_planner=false"
+
+    sql "DROP TABLE IF EXISTS test_prune_tablet_t2"
+    sql """
+           CREATE TABLE `test_prune_tablet_t2` (
+                     `id` INT NULL,
+                     `c1` BOOLEAN NULL,
+                     `id2` BIGINT NULL,
+                     `id3` BIGINT NULL,
+                     `id4` BIGINT NULL
+                    ) distributed by hash(id) BUCKETS 16 
properties('replication_num'='1');
+    """
+
+    createMV( """
+           alter table test_prune_tablet_t2 add rollup 
example_rollup_index(c1,id); 
+    """)
+
+    sql """insert into test_prune_tablet_t2 values
+            (1,0,1,1,1),
+            (2,0,2,2,2),
+            (3,0,3,3,3),
+            (4,0,4,4,4),
+            (5,0,5,5,5),
+            (6,0,6,6,6),
+            (7,0,7,7,7);"""
+
+    explain {
+        sql("select id,sum(c1) from test_prune_tablet_t2 where c1=0 and id = 3 
group by id;")
+        contains "example_rollup_index"
+        contains "tablets=1/16"
+    }
+
+    sql "DROP TABLE IF EXISTS test_prune_tablet_t2"
+}
\ 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

Reply via email to