-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[fix](mtmv) Fix query rewrite by mv fail when both use cte and group sets #57741
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[fix](mtmv) Fix query rewrite by mv fail when both use cte and group sets #57741
Conversation
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
|
run buildall |
FE UT Coverage ReportIncrement line coverage |
TPC-DS: Total hot run time: 189866 ms |
ClickBench: Total hot run time: 27.62 s |
FE Regression Coverage ReportIncrement line coverage |
|
run buildall |
1 similar comment
|
run buildall |
TPC-DS: Total hot run time: 189251 ms |
ClickBench: Total hot run time: 27.7 s |
FE UT Coverage ReportIncrement line coverage |
FE Regression Coverage ReportIncrement line coverage |
e0a9893 to
adcc93e
Compare
|
run buildall |
TPC-DS: Total hot run time: 189266 ms |
ClickBench: Total hot run time: 27.36 s |
FE Regression Coverage ReportIncrement line coverage |
|
run buildall |
TPC-DS: Total hot run time: 189104 ms |
ClickBench: Total hot run time: 27.36 s |
|
PR approved by at least one committer and no changes requested. |
|
PR approved by anyone and no changes requested. |
e0b271f to
0e86ad0
Compare
FE Regression Coverage ReportIncrement line coverage |
86ffb4e to
716b025
Compare
|
run buildall |
FE UT Coverage ReportIncrement line coverage |
FE Regression Coverage ReportIncrement line coverage |
2 similar comments
FE Regression Coverage ReportIncrement line coverage |
FE Regression Coverage ReportIncrement line coverage |
|
run buildall |
TPC-DS: Total hot run time: 182857 ms |
ClickBench: Total hot run time: 27.68 s |
FE UT Coverage ReportIncrement line coverage |
FE Regression Coverage ReportIncrement line coverage |
3 similar comments
FE Regression Coverage ReportIncrement line coverage |
FE Regression Coverage ReportIncrement line coverage |
FE Regression Coverage ReportIncrement line coverage |
|
PR approved by at least one committer and no changes requested. |
…sets (#57741) Fix query rewrite by mv fail when both use cte and group sets Such as mv def is as following: ```sql select l_shipdate, o_orderdate, l_partkey, l_suppkey, 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 lineitem left join orders on lineitem.l_orderkey = orders.o_orderkey and l_shipdate = o_orderdate group by l_shipdate, o_orderdate, l_partkey, l_suppkey; ``` query is as fllowing, use both group sets and cte, would rewrite fail, the pr fix this ```sql with t as ( select t1.l_partkey, t1.l_suppkey, o_orderdate, grouping(t1.l_suppkey), grouping(o_orderdate), grouping_id(t1.l_partkey, t1.l_suppkey), grouping_id(t1.l_partkey, t1.l_suppkey, o_orderdate), 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 (select * from lineitem where l_shipdate = '2023-12-11') t1 left join orders on t1.l_orderkey = orders.o_orderkey and t1.l_shipdate = o_orderdate group by GROUPING SETS ((l_shipdate, o_orderdate, l_partkey), (l_partkey, l_suppkey), (l_suppkey), ()) ) select t1.l_suppkey, t2.o_orderdate from t t1 inner join t t2 on t1.l_partkey = t2.l_partkey; ```
…sets (apache#57741) Fix query rewrite by mv fail when both use cte and group sets Such as mv def is as following: ```sql select l_shipdate, o_orderdate, l_partkey, l_suppkey, 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 lineitem left join orders on lineitem.l_orderkey = orders.o_orderkey and l_shipdate = o_orderdate group by l_shipdate, o_orderdate, l_partkey, l_suppkey; ``` query is as fllowing, use both group sets and cte, would rewrite fail, the pr fix this ```sql with t as ( select t1.l_partkey, t1.l_suppkey, o_orderdate, grouping(t1.l_suppkey), grouping(o_orderdate), grouping_id(t1.l_partkey, t1.l_suppkey), grouping_id(t1.l_partkey, t1.l_suppkey, o_orderdate), 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 (select * from lineitem where l_shipdate = '2023-12-11') t1 left join orders on t1.l_orderkey = orders.o_orderkey and t1.l_shipdate = o_orderdate group by GROUPING SETS ((l_shipdate, o_orderdate, l_partkey), (l_partkey, l_suppkey), (l_suppkey), ()) ) select t1.l_suppkey, t2.o_orderdate from t t1 inner join t t2 on t1.l_partkey = t2.l_partkey; ```
What problem does this PR solve?
Fix query rewrite by mv fail when both use cte and group sets
Such as mv def is as following:
query is as fllowing, use both group sets and cte, would rewrite fail, the pr fix this
Issue Number: close #xxx
Related PR: #36056
Problem Summary:
Release note
None
Check List (For Author)
Test
Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)