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

[fix](mtmv) Fix enable_materialized_view_nest_rewrite session variable is useless in some scene #41472

Merged
merged 2 commits into from
Oct 11, 2024

Conversation

seawinde
Copy link
Contributor

Proposed changes

This is brought by #34050

if set enable_materialized_view_nest_rewrite = false, as expected, top level materialized view should rewritten fail, but now successfully.

Such as first level materialized view def is

        CREATE MATERIALIZED VIEW level1
        BUILD IMMEDIATE REFRESH COMPLETE ON MANUAL
        DISTRIBUTED BY RANDOM BUCKETS 2
        PROPERTIES ('replication_num' = '1') 
        AS
    SELECT l_orderkey, l_linenumber, l_partkey, o_orderkey, o_custkey
    FROM lineitem_2 INNER JOIN orders_2
    ON l_orderkey = o_orderkey;

second level materialized view def is

        CREATE MATERIALIZED VIEW level2
        BUILD IMMEDIATE REFRESH COMPLETE ON MANUAL
        DISTRIBUTED BY RANDOM BUCKETS 2
        PROPERTIES ('replication_num' = '1') 
        AS
    SELECT
    l_orderkey,
    l_linenumber,
    o_orderkey,
    sum(l_partkey) AS total_revenue,
    max(o_custkey) AS max_discount
    FROM join_mv1
    GROUP BY l_orderkey, l_linenumber, o_orderkey;

if set enable_materialized_view_nest_rewrite = false, only level1 can rewriten succesfully and chosen by cbo
if set enable_materialized_view_nest_rewrite = true, both level1 and level2 can rewriten succesfully and level2 should be chosen by cbo.

This pr fixed this

@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

run buildall

@seawinde seawinde force-pushed the fix_nest_mv_rewrite_variable_fail branch from 9327087 to a6b1df7 Compare September 30, 2024 08:52
@seawinde
Copy link
Contributor Author

run buildall

@seawinde seawinde force-pushed the fix_nest_mv_rewrite_variable_fail branch from a6b1df7 to 9e968a1 Compare October 8, 2024 12:34
@seawinde
Copy link
Contributor Author

seawinde commented Oct 8, 2024

run buildall

Copy link
Contributor

PR approved by at least one committer and no changes requested.

@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Oct 10, 2024
Copy link
Contributor

PR approved by anyone and no changes requested.

@morrySnow morrySnow merged commit 2745e04 into apache:master Oct 11, 2024
25 of 28 checks passed
@morrySnow morrySnow added the p0_b label Oct 17, 2024
seawinde added a commit to seawinde/doris that referenced this pull request Oct 21, 2024
…e is useless in some scene (apache#41472)

This is brought by apache#34050

if set `enable_materialized_view_nest_rewrite = false`, as expected, top
level materialized view should rewritten fail, but now successfully.

Such as first level materialized view def is

        CREATE MATERIALIZED VIEW level1
        BUILD IMMEDIATE REFRESH COMPLETE ON MANUAL
        DISTRIBUTED BY RANDOM BUCKETS 2
        PROPERTIES ('replication_num' = '1')
        AS
    SELECT l_orderkey, l_linenumber, l_partkey, o_orderkey, o_custkey
    FROM lineitem_2 INNER JOIN orders_2
    ON l_orderkey = o_orderkey;

second level materialized view def is

        CREATE MATERIALIZED VIEW level2
        BUILD IMMEDIATE REFRESH COMPLETE ON MANUAL
        DISTRIBUTED BY RANDOM BUCKETS 2
        PROPERTIES ('replication_num' = '1')
        AS
    SELECT
    l_orderkey,
    l_linenumber,
    o_orderkey,
    sum(l_partkey) AS total_revenue,
    max(o_custkey) AS max_discount
    FROM join_mv1
    GROUP BY l_orderkey, l_linenumber, o_orderkey;

if set `enable_materialized_view_nest_rewrite = false`, only `level1`
can rewriten succesfully and chosen by cbo
if set `enable_materialized_view_nest_rewrite = true`, both `level1` and
`level2` can rewriten succesfully and `level2` should be chosen by cbo.

This pr fixed this
seawinde added a commit to seawinde/doris that referenced this pull request Oct 23, 2024
…e is useless in some scene (apache#41472)

This is brought by apache#34050

if set `enable_materialized_view_nest_rewrite = false`, as expected, top
level materialized view should rewritten fail, but now successfully.

Such as first level materialized view def is

        CREATE MATERIALIZED VIEW level1
        BUILD IMMEDIATE REFRESH COMPLETE ON MANUAL
        DISTRIBUTED BY RANDOM BUCKETS 2
        PROPERTIES ('replication_num' = '1')
        AS
    SELECT l_orderkey, l_linenumber, l_partkey, o_orderkey, o_custkey
    FROM lineitem_2 INNER JOIN orders_2
    ON l_orderkey = o_orderkey;

second level materialized view def is

        CREATE MATERIALIZED VIEW level2
        BUILD IMMEDIATE REFRESH COMPLETE ON MANUAL
        DISTRIBUTED BY RANDOM BUCKETS 2
        PROPERTIES ('replication_num' = '1')
        AS
    SELECT
    l_orderkey,
    l_linenumber,
    o_orderkey,
    sum(l_partkey) AS total_revenue,
    max(o_custkey) AS max_discount
    FROM join_mv1
    GROUP BY l_orderkey, l_linenumber, o_orderkey;

if set `enable_materialized_view_nest_rewrite = false`, only `level1`
can rewriten succesfully and chosen by cbo
if set `enable_materialized_view_nest_rewrite = true`, both `level1` and
`level2` can rewriten succesfully and `level2` should be chosen by cbo.

This pr fixed this
seawinde added a commit to seawinde/doris that referenced this pull request Oct 23, 2024
…e is useless in some scene (apache#41472)

This is brought by apache#34050

if set `enable_materialized_view_nest_rewrite = false`, as expected, top
level materialized view should rewritten fail, but now successfully.

Such as first level materialized view def is

        CREATE MATERIALIZED VIEW level1
        BUILD IMMEDIATE REFRESH COMPLETE ON MANUAL
        DISTRIBUTED BY RANDOM BUCKETS 2
        PROPERTIES ('replication_num' = '1') 
        AS
    SELECT l_orderkey, l_linenumber, l_partkey, o_orderkey, o_custkey
    FROM lineitem_2 INNER JOIN orders_2
    ON l_orderkey = o_orderkey;

second level materialized view def is

        CREATE MATERIALIZED VIEW level2
        BUILD IMMEDIATE REFRESH COMPLETE ON MANUAL
        DISTRIBUTED BY RANDOM BUCKETS 2
        PROPERTIES ('replication_num' = '1') 
        AS
    SELECT
    l_orderkey,
    l_linenumber,
    o_orderkey,
    sum(l_partkey) AS total_revenue,
    max(o_custkey) AS max_discount
    FROM join_mv1
    GROUP BY l_orderkey, l_linenumber, o_orderkey;

if set `enable_materialized_view_nest_rewrite = false`, only `level1`
can rewriten succesfully and chosen by cbo
if set `enable_materialized_view_nest_rewrite = true`, both `level1` and
`level2` can rewriten succesfully and `level2` should be chosen by cbo.

This pr fixed this
yiguolei pushed a commit that referenced this pull request Oct 24, 2024
morrySnow pushed a commit that referenced this pull request Oct 24, 2024
pick from master

pr: #41472
commitId: 2745e04

pr: #40106
commitId: 0fdb1ee

pr: #40173
commitId: 0d07e3d

pr: #42206
commitId: 2bcaa5b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by one committer. dev/2.1.7-merged dev/3.0.3-merged p0_b reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants