Skip to content
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

[feature](mtmv) Support query rewrite by materialized view when query is aggregate and materialized view has no aggregate (#36278) #37497

Merged

Conversation

seawinde
Copy link
Contributor

@seawinde seawinde commented Jul 8, 2024

Proposed changes

cherry-pick to 2.1
pr: #36278
commitId: 649f9bc

@doris-robot
Copy link

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR

Since 2024-03-18, the Document has been moved to doris-website.
See Doris Document.

@seawinde
Copy link
Contributor Author

seawinde commented Jul 8, 2024

run buildall

1 similar comment
@morrySnow
Copy link
Contributor

run buildall

…y is aggregate and materialized view has no aggregate (apache#36278)

## Proposed changes

Support query rewrite by materialized view when query is aggregate and
materialized view has no aggregate
this maybe improve query spped, because it can save expression
evaluation by use the expression result in materialized view.

this also support single table rewrite.

For example as follwoing:
mv def is:

>            CREATE MATERIALIZED VIEW mv1
>             BUILD IMMEDIATE REFRESH COMPLETE ON MANUAL
>             DISTRIBUTED BY RANDOM BUCKETS 2
>             PROPERTIES ('replication_num' = '1') 
>             AS
> select case when o_shippriority > 1 and o_orderkey IN (4, 5) then
o_custkey else o_shippriority end,
>              o_orderstatus,
>              bin(o_orderkey),
>              l_suppkey,
>              l_linenumber
>              from orders
>              left join lineitem on o_orderkey =  l_orderkey;


the query as following can be rewritten by mv successfully

>             select
> count(case when o_shippriority > 1 and o_orderkey IN (4, 5) then
o_custkey else o_shippriority end) as count_case,
>             o_orderstatus,
>             bin(o_orderkey)
>             from orders
>             left join lineitem on o_orderkey =  l_orderkey
>             where l_linenumber = 4
>            group by
>             o_orderstatus,
>             bin(o_orderkey);
@seawinde seawinde force-pushed the support_agg_on_no_agg_mv_rewrite branch from f3c0c00 to 92b4dec Compare July 10, 2024 09:03
@seawinde
Copy link
Contributor Author

run buildall

@morrySnow morrySnow merged commit 1eb04cf into apache:branch-2.1 Jul 11, 2024
20 of 21 checks passed
@yiguolei yiguolei mentioned this pull request Jul 19, 2024
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants