-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[improvement](mtmv) Not roll up when aggregate rewrite if roll up gro…
…up by expr is uniform (#38387) ## Proposed changes Not roll up when aggregate rewrite if roll up group by expr is uniform Such as mv name is mv3_0, and def is: ```sql CREATE MATERIALIZED VIEW mv3_0 BUILD IMMEDIATE REFRESH COMPLETE ON MANUAL DISTRIBUTED BY RANDOM BUCKETS 2 PROPERTIES ('replication_num' = '1') AS select o_orderdate, o_shippriority, o_comment, sum(o_totalprice) as sum_total, max(o_totalprice) as max_total, min(o_totalprice) as min_total, count(*) as count_all from orders group by o_orderdate, o_shippriority, o_comment; ``` query sql is as following: ```sql select o_comment, sum(o_totalprice), max(o_totalprice), min(o_totalprice), count(*) from orders where o_orderdate = '2023-12-09' and o_shippriority = 1 group by o_comment; ``` after rewrite the plan is as following, not need to add aggregate ``` PhysicalResultSink --filter((mv3_0.o_orderdate = '2023-12-09') and (mv3_0.o_shippriority = 1)) ----PhysicalOlapScan[mv3_0] ```
- Loading branch information
1 parent
eb17f8a
commit d73e5f2
Showing
5 changed files
with
774 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
125 changes: 125 additions & 0 deletions
125
...ion-test/data/nereids_rules_p0/mv/agg_optimize_when_uniform/agg_optimize_when_uniform.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
-- This file is automatically generated. You should know what you did if you want to edit this | ||
-- !query1_0_before -- | ||
2023-12-10 46.00 33.50 2 0 | ||
|
||
-- !shape1_0_after -- | ||
PhysicalResultSink | ||
--hashAgg[GLOBAL] | ||
----hashAgg[LOCAL] | ||
------filter((mv1_0.o_custkey = 1) and (mv1_0.o_orderkey = 3)) | ||
--------PhysicalOlapScan[mv1_0] | ||
|
||
-- !query1_0_after -- | ||
2023-12-10 46.00 33.50 2 0 | ||
|
||
-- !query2_0_before -- | ||
2 2 2 1.0 1.0 1 1 | ||
|
||
-- !shape2_0_after -- | ||
PhysicalResultSink | ||
--hashAgg[DISTINCT_LOCAL] | ||
----hashAgg[GLOBAL] | ||
------hashAgg[LOCAL] | ||
--------filter((mv2_0.o_orderkey = 1) and (mv2_0.o_orderstatus = 'o')) | ||
----------PhysicalOlapScan[mv2_0] | ||
|
||
-- !query2_0_after -- | ||
2 2 2 1.0 1.0 1 1 | ||
|
||
-- !query3_0_before -- | ||
yy 11.50 11.50 11.50 1 | ||
|
||
-- !shape3_0_after -- | ||
PhysicalResultSink | ||
--filter((mv3_0.o_orderdate = '2023-12-09') and (mv3_0.o_shippriority = 1)) | ||
----PhysicalOlapScan[mv3_0] | ||
|
||
-- !query3_0_after -- | ||
yy 11.50 11.50 11.50 1 | ||
|
||
-- !query3_1_before -- | ||
mi 56.20 56.20 56.20 1 | ||
|
||
-- !shape3_1_after -- | ||
PhysicalResultSink | ||
--hashAgg[GLOBAL] | ||
----hashAgg[LOCAL] | ||
------filter((orders.o_orderdate = '2023-12-12') and (orders.o_shippriority = 2) and (orders.o_totalprice = 56.20)) | ||
--------PhysicalOlapScan[orders] | ||
|
||
-- !query3_1_after -- | ||
mi 56.20 56.20 56.20 1 | ||
|
||
-- !query4_0_before -- | ||
yy 11.50 11.50 11.50 1 | ||
|
||
-- !query4_0_after -- | ||
yy 11.50 11.50 11.50 1 | ||
|
||
-- !query5_0_before -- | ||
3 2023-12-12 57.40 56.20 2 0 | ||
|
||
-- !shape5_0_after -- | ||
PhysicalResultSink | ||
--hashAgg[GLOBAL] | ||
----hashAgg[LOCAL] | ||
------filter((mv5_0.l_partkey = 2) and (mv5_0.l_shipdate = '2023-12-12')) | ||
--------PhysicalOlapScan[mv5_0] | ||
|
||
-- !query5_0_after -- | ||
3 2023-12-12 57.40 56.20 2 0 | ||
|
||
-- !query6_0_before -- | ||
2 2 2 2 1.0 1.0 1 1 | ||
|
||
-- !shape6_0_after -- | ||
PhysicalResultSink | ||
--hashAgg[DISTINCT_LOCAL] | ||
----hashAgg[GLOBAL] | ||
------hashAgg[LOCAL] | ||
--------filter((mv6_0.o_orderkey = 1) and (mv6_0.o_orderstatus = 'o')) | ||
----------PhysicalOlapScan[mv6_0] | ||
|
||
-- !query6_0_after -- | ||
2 2 2 2 1.0 1.0 1 1 | ||
|
||
-- !query7_0_before -- | ||
yy 4 11.50 11.50 11.50 1 | ||
|
||
-- !shape7_0_after -- | ||
PhysicalResultSink | ||
--filter((mv7_0.o_orderdate = '2023-12-09') and (mv7_0.o_shippriority = 1)) | ||
----PhysicalOlapScan[mv7_0] | ||
|
||
-- !query7_0_after -- | ||
yy 4 11.50 11.50 11.50 1 | ||
|
||
-- !query7_1_before -- | ||
yy 4 11.50 11.50 11.50 1 | ||
|
||
-- !shape7_1_after -- | ||
PhysicalResultSink | ||
--hashAgg[GLOBAL] | ||
----hashAgg[LOCAL] | ||
------hashJoin[INNER_JOIN] hashCondition=((t1.l_orderkey = orders.o_orderkey) and (t1.l_shipdate = orders.o_orderdate)) otherCondition=() | ||
--------filter((t1.l_shipdate = '2023-12-09')) | ||
----------PhysicalOlapScan[lineitem] | ||
--------filter((orders.o_orderdate = '2023-12-09') and (orders.o_shippriority = 1) and (orders.o_totalprice = 11.50)) | ||
----------PhysicalOlapScan[orders] | ||
|
||
-- !query7_1_after -- | ||
yy 4 11.50 11.50 11.50 1 | ||
|
||
-- !query8_0_before -- | ||
yy 4 11.50 11.50 11.50 1 | ||
|
||
-- !shape8_0_after -- | ||
PhysicalResultSink | ||
--hashAgg[GLOBAL] | ||
----hashAgg[LOCAL] | ||
------filter((mv8_0.o_orderdate = '2023-12-09')) | ||
--------PhysicalOlapScan[mv8_0] | ||
|
||
-- !query8_0_after -- | ||
yy 4 11.50 11.50 11.50 1 | ||
|
Oops, something went wrong.