This is an automated email from the ASF dual-hosted git repository.
morrysnow pushed a commit to branch branch-3.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.1 by this push:
new 346c813dcf7 branch-3.1: [fix](mtmv) Fix mv rewrite fail when mv
contains group sets and filter above scan #57343 (#57674)
346c813dcf7 is described below
commit 346c813dcf7fcfb349761d4f2fd451ab7b8053f0
Author: seawinde <[email protected]>
AuthorDate: Thu Nov 6 12:11:02 2025 +0800
branch-3.1: [fix](mtmv) Fix mv rewrite fail when mv contains group sets and
filter above scan #57343 (#57674)
picked from #57343
---
.../nereids/rules/exploration/mv/StructInfo.java | 6 ++--
.../mv/grouping_sets/grouping_sets.out | 10 ++++++
.../mv/grouping_sets/grouping_sets.groovy | 37 ++++++++++++++++++++++
3 files changed, 51 insertions(+), 2 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/StructInfo.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/StructInfo.java
index 3b3f47e1f84..0d976fee8f8 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/StructInfo.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/StructInfo.java
@@ -83,8 +83,8 @@ public class StructInfo {
public static final ScanPlanPatternChecker SCAN_PLAN_PATTERN_CHECKER = new
ScanPlanPatternChecker();
// struct info splitter
public static final PlanSplitter PLAN_SPLITTER = new PlanSplitter();
- private static final RelationCollector RELATION_COLLECTOR = new
RelationCollector();
private static final PredicateCollector PREDICATE_COLLECTOR = new
PredicateCollector();
+ private static final RelationCollector RELATION_COLLECTOR = new
RelationCollector();
// source data
private final Plan originalPlan;
private final ObjectId originalPlanId;
@@ -493,7 +493,9 @@ public class StructInfo {
// Just collect the filter in top plan, if meet other node except
project and filter, return
if (!(plan instanceof LogicalProject)
&& !(plan instanceof LogicalFilter)
- && !(plan instanceof LogicalAggregate)) {
+ && !(plan instanceof LogicalAggregate)
+ && !(plan instanceof LogicalSort)
+ && !(plan instanceof LogicalRepeat)) {
return null;
}
if (plan instanceof LogicalFilter) {
diff --git
a/regression-test/data/nereids_rules_p0/mv/grouping_sets/grouping_sets.out
b/regression-test/data/nereids_rules_p0/mv/grouping_sets/grouping_sets.out
index b6e7a275984..16e370a993d 100644
--- a/regression-test/data/nereids_rules_p0/mv/grouping_sets/grouping_sets.out
+++ b/regression-test/data/nereids_rules_p0/mv/grouping_sets/grouping_sets.out
@@ -163,6 +163,16 @@ o \N 1 0 0 178.10 56.20 1.20
8 0
o a 0 0 0 77.50 33.50 9.50 5 0
o c 0 0 0 100.60 56.20 1.20 3 0
+-- !query10_1_before --
+\N \N 3 1 1 100.60 56.20 1.20 3 0
+o \N 1 0 0 100.60 56.20 1.20 3 0
+o c 0 0 0 100.60 56.20 1.20 3 0
+
+-- !query10_1_after --
+\N \N 3 1 1 100.60 56.20 1.20 3 0
+o \N 1 0 0 100.60 56.20 1.20 3 0
+o c 0 0 0 100.60 56.20 1.20 3 0
+
-- !query11_0_before --
\N \N \N 43.20 43.20 43.20 1 0
3 \N \N 43.20 43.20 43.20 1 0
diff --git
a/regression-test/suites/nereids_rules_p0/mv/grouping_sets/grouping_sets.groovy
b/regression-test/suites/nereids_rules_p0/mv/grouping_sets/grouping_sets.groovy
index 4655f9d004b..26894356580 100644
---
a/regression-test/suites/nereids_rules_p0/mv/grouping_sets/grouping_sets.groovy
+++
b/regression-test/suites/nereids_rules_p0/mv/grouping_sets/grouping_sets.groovy
@@ -473,6 +473,43 @@ suite("materialized_view_grouping_sets") {
order_qt_query10_0_after "${query10_0}"
sql """ DROP MATERIALIZED VIEW IF EXISTS mv10_0"""
+
+ // single table rollup with grouping scalar function and filter
+ def mv10_1 =
+ """
+ select o_orderstatus, o_orderdate, o_orderpriority,
+ sum(o_totalprice) as sum_total,
+ max(o_totalprice) as max_total,
+ min(o_totalprice) as min_total,
+ count(*) as count_all,
+ bitmap_union(to_bitmap(case when o_shippriority > 1 and o_orderkey
IN (1, 3) then o_custkey else null end)) as bitmap_union_basic
+ from orders
+ where o_custkey > 1
+ group by
+ o_orderstatus, o_orderdate, o_orderpriority;
+ """
+ def query10_1 =
+ """
+ select o_orderstatus, o_orderpriority,
+ grouping_id(o_orderstatus, o_orderpriority),
+ grouping_id(o_orderstatus),
+ grouping(o_orderstatus),
+ sum(o_totalprice),
+ max(o_totalprice),
+ min(o_totalprice),
+ count(*),
+ count(distinct case when o_shippriority > 1 and o_orderkey IN (1,
3) then o_custkey else null end)
+ from orders
+ where o_custkey > 1
+ group by
+ ROLLUP (o_orderstatus, o_orderpriority);
+ """
+ order_qt_query10_1_before "${query10_1}"
+ async_mv_rewrite_success(db, mv10_1, query10_1, "mv10_1")
+ order_qt_query10_1_after "${query10_1}"
+ sql """ DROP MATERIALIZED VIEW IF EXISTS mv10_1"""
+
+
// multi table rollup without grouping scalar function
def mv11_0 =
"""
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]