[fix](mtmv) Fix mv rewrite fail when mv contains group sets and filter above scan#57343
Merged
morrySnow merged 2 commits intoapache:masterfrom Nov 3, 2025
Merged
Conversation
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
Contributor
Author
|
run buildall |
ClickBench: Total hot run time: 28.26 s |
Contributor
Author
|
run buildall |
TPC-DS: Total hot run time: 189302 ms |
ClickBench: Total hot run time: 27.68 s |
Contributor
FE UT Coverage ReportIncrement line coverage |
Contributor
|
PR approved by anyone and no changes requested. |
morrySnow
approved these changes
Nov 3, 2025
| private static class PredicateCollector extends DefaultPlanVisitor<Void, Set<Expression>> { | ||
| @Override | ||
| public Void visit(Plan plan, Set<Expression> predicates) { | ||
| // Just collect the filter in top plan, if meet other node except project and filter, return |
Contributor
|
PR approved by at least one committer and no changes requested. |
github-actions bot
pushed a commit
that referenced
this pull request
Nov 3, 2025
…r above scan (#57343) ### What problem does this PR solve? Related PR: #36056 Problem Summary: if mv is defined as following CREATE MATERIALIZED VIEW mv_11 BUILD IMMEDIATE REFRESH COMPLETE ON MANUAL DISTRIBUTED BY RANDOM BUCKETS 2 PROPERTIES ('replication_num' = '1') AS 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; there is filter `where o_custkey > 1` in mv, if query is as following, should be rewritten successfully but fail, because the filter `o_custkey > 1` is lost compare and could not compensate the filter, the pr fixed this. 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);
github-actions bot
pushed a commit
that referenced
this pull request
Nov 3, 2025
…r above scan (#57343) ### What problem does this PR solve? Related PR: #36056 Problem Summary: if mv is defined as following CREATE MATERIALIZED VIEW mv_11 BUILD IMMEDIATE REFRESH COMPLETE ON MANUAL DISTRIBUTED BY RANDOM BUCKETS 2 PROPERTIES ('replication_num' = '1') AS 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; there is filter `where o_custkey > 1` in mv, if query is as following, should be rewritten successfully but fail, because the filter `o_custkey > 1` is lost compare and could not compensate the filter, the pr fixed this. 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);
seawinde
added a commit
to seawinde/doris
that referenced
this pull request
Nov 4, 2025
…r above scan (apache#57343) ### What problem does this PR solve? Related PR: apache#36056 Problem Summary: if mv is defined as following CREATE MATERIALIZED VIEW mv_11 BUILD IMMEDIATE REFRESH COMPLETE ON MANUAL DISTRIBUTED BY RANDOM BUCKETS 2 PROPERTIES ('replication_num' = '1') AS 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; there is filter `where o_custkey > 1` in mv, if query is as following, should be rewritten successfully but fail, because the filter `o_custkey > 1` is lost compare and could not compensate the filter, the pr fixed this. 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);
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem does this PR solve?
if mv is defined as following
CREATE MATERIALIZED VIEW mv_11 BUILD IMMEDIATE REFRESH COMPLETE ON MANUAL DISTRIBUTED BY RANDOM BUCKETS 2 PROPERTIES ('replication_num' = '1') AS 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;there is filter
where o_custkey > 1in mv, if query is as following, should be rewritten successfully but fail, because the filtero_custkey > 1is lost compare and could not compensate the filter, the pr fixed 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)