Skip to content

Commit fc43885

Browse files
committed
[improvement](mtmv) Not roll up when aggregate rewrite if roll up group by expr is uniform
1 parent 72dff44 commit fc43885

File tree

4 files changed

+498
-75
lines changed

4 files changed

+498
-75
lines changed
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
-- This file is automatically generated. You should know what you did if you want to edit this
2+
-- !query1_0_before --
3+
2023-12-10 46.00 33.50 2 0
4+
5+
-- !shape1_0_after --
6+
PhysicalResultSink
7+
--hashAgg[GLOBAL]
8+
----hashAgg[LOCAL]
9+
------filter((mv1_0.o_custkey = 1) and (mv1_0.o_orderkey = 3))
10+
--------PhysicalOlapScan[mv1_0]
11+
12+
-- !query1_0_after --
13+
2023-12-10 46.00 33.50 2 0
14+
15+
-- !query2_0_before --
16+
2 2 2 1.0 1.0 1 1
17+
18+
-- !shape2_0_after --
19+
PhysicalResultSink
20+
--hashAgg[DISTINCT_LOCAL]
21+
----hashAgg[GLOBAL]
22+
------hashAgg[LOCAL]
23+
--------filter((mv2_0.o_orderkey = 1) and (mv2_0.o_orderstatus = 'o'))
24+
----------PhysicalOlapScan[mv2_0]
25+
26+
-- !query2_0_after --
27+
2 2 2 1.0 1.0 1 1
28+
29+
-- !query3_0_before --
30+
yy 11.50 11.50 11.50 1
31+
32+
-- !shape3_0_after --
33+
PhysicalResultSink
34+
--filter((mv3_0.o_orderdate = '2023-12-09') and (mv3_0.o_shippriority = 1))
35+
----PhysicalOlapScan[mv3_0]
36+
37+
-- !query3_0_after --
38+
yy 11.50 11.50 11.50 1
39+
40+
-- !query3_1_before --
41+
42+
-- !shape3_1_after --
43+
PhysicalResultSink
44+
--hashAgg[GLOBAL]
45+
----hashAgg[LOCAL]
46+
------filter((cast(o_shippriority as DOUBLE) = cast('a' as DOUBLE)) and (orders.o_orderdate = '2023-12-09') and (orders.o_totalprice = 11.50))
47+
--------PhysicalOlapScan[orders]
48+
49+
-- !query3_1_after --
50+
51+
-- !query4_0_before --
52+
yy 11.50 11.50 11.50 1
53+
54+
-- !shape4_0_after --
55+
PhysicalResultSink
56+
--hashAgg[GLOBAL]
57+
----hashAgg[LOCAL]
58+
------filter((orders.o_orderdate = '2023-12-09'))
59+
--------PhysicalOlapScan[orders]
60+
61+
-- !query4_0_after --
62+
yy 11.50 11.50 11.50 1
63+
64+
-- !query5_0_before --
65+
3 2023-12-12 57.40 56.20 2 0
66+
67+
-- !shape5_0_after --
68+
PhysicalResultSink
69+
--hashAgg[GLOBAL]
70+
----hashAgg[LOCAL]
71+
------filter((mv5_0.l_partkey = 2) and (mv5_0.l_shipdate = '2023-12-12'))
72+
--------PhysicalOlapScan[mv5_0]
73+
74+
-- !query5_0_after --
75+
3 2023-12-12 57.40 56.20 2 0
76+
77+
-- !query6_0_before --
78+
2 2 2 2 1.0 1.0 1 1
79+
80+
-- !shape6_0_after --
81+
PhysicalResultSink
82+
--hashAgg[DISTINCT_LOCAL]
83+
----hashAgg[GLOBAL]
84+
------hashAgg[LOCAL]
85+
--------filter((mv6_0.o_orderkey = 1) and (mv6_0.o_orderstatus = 'o'))
86+
----------PhysicalOlapScan[mv6_0]
87+
88+
-- !query6_0_after --
89+
2 2 2 2 1.0 1.0 1 1
90+
91+
-- !query7_0_before --
92+
yy 4 11.50 11.50 11.50 1
93+
94+
-- !shape7_0_after --
95+
PhysicalResultSink
96+
--filter((mv7_0.o_orderdate = '2023-12-09') and (mv7_0.o_shippriority = 1))
97+
----PhysicalOlapScan[mv7_0]
98+
99+
-- !query7_0_after --
100+
yy 4 11.50 11.50 11.50 1
101+
102+
-- !query7_1_before --
103+
104+
-- !shape7_1_after --
105+
PhysicalResultSink
106+
--hashAgg[GLOBAL]
107+
----hashAgg[LOCAL]
108+
------hashJoin[INNER_JOIN] hashCondition=((t1.l_orderkey = orders.o_orderkey) and (t1.l_shipdate = orders.o_orderdate)) otherCondition=()
109+
--------filter((t1.l_shipdate = '2023-12-09'))
110+
----------PhysicalOlapScan[lineitem]
111+
--------filter((cast(o_shippriority as DOUBLE) = cast('a' as DOUBLE)) and (orders.o_orderdate = '2023-12-09') and (orders.o_totalprice = 11.50))
112+
----------PhysicalOlapScan[orders]
113+
114+
-- !query7_1_after --
115+
116+
-- !query8_0_before --
117+
yy 4 11.50 11.50 11.50 1
118+
119+
-- !shape8_0_after --
120+
PhysicalResultSink
121+
--hashAgg[GLOBAL]
122+
----hashAgg[LOCAL]
123+
------filter((mv8_0.o_orderdate = '2023-12-09'))
124+
--------PhysicalOlapScan[mv8_0]
125+
126+
-- !query8_0_after --
127+
yy 4 11.50 11.50 11.50 1
128+

regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/Suite.groovy

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,6 +1475,28 @@ class Suite implements GroovyInterceptable {
14751475
}
14761476
}
14771477

1478+
def check_mv_rewrite_successs_without_check_chosen = {db, mv_sql, query_sql, mv_name ->
1479+
1480+
sql """DROP MATERIALIZED VIEW IF EXISTS ${mv_name}"""
1481+
sql"""
1482+
CREATE MATERIALIZED VIEW ${mv_name}
1483+
BUILD IMMEDIATE REFRESH COMPLETE ON MANUAL
1484+
DISTRIBUTED BY RANDOM BUCKETS 2
1485+
PROPERTIES ('replication_num' = '1')
1486+
AS ${mv_sql}
1487+
"""
1488+
1489+
def job_name = getJobName(db, mv_name);
1490+
waitingMTMVTaskFinished(job_name)
1491+
explain {
1492+
sql("${query_sql}")
1493+
check {result ->
1494+
def splitResult = result.split("MaterializedViewRewriteFail")
1495+
splitResult.length == 2 ? splitResult[0].contains(mv_name) : false
1496+
}
1497+
}
1498+
}
1499+
14781500
def check_mv_rewrite_fail = { db, mv_sql, query_sql, mv_name ->
14791501

14801502
sql """DROP MATERIALIZED VIEW IF EXISTS ${mv_name}"""

0 commit comments

Comments
 (0)