Skip to content

[fix](mv) Support relation implied predicates for nested MV rewrite#63571

Closed
foxtail463 wants to merge 2 commits into
apache:masterfrom
foxtail463:fix/nested-mv-relation-implied-predicates
Closed

[fix](mv) Support relation implied predicates for nested MV rewrite#63571
foxtail463 wants to merge 2 commits into
apache:masterfrom
foxtail463:fix/nested-mv-relation-implied-predicates

Conversation

@foxtail463
Copy link
Copy Markdown
Contributor

@foxtail463 foxtail463 commented May 25, 2026

Problem Summary:

Nested MV rewrite may fail to use predicates carried by a lower MV scan.

CREATE MATERIALIZED VIEW mv_fact AS
SELECT k1, dim_id, sku_type, amount
FROM fact
WHERE sku_type = '1';

CREATE MATERIALIZED VIEW mv_join AS
SELECT f.k1, f.dim_id, f.sku_type, f.amount, d.tag
FROM mv_fact f
JOIN dim d ON f.dim_id = d.dim_id
WHERE f.sku_type = '1';

SELECT f.k1, f.dim_id, f.sku_type, f.amount, d.tag
FROM fact f
JOIN dim d ON f.dim_id = d.dim_id
WHERE f.sku_type = '1';

The lower MV scan semantically carries sku_type = '1'. During nested MV rewrite, this predicate must be visible when matching and compensating predicates for the upper MV. If the MV scan does not carry relation-implied predicates, the rewrite may fail even though mv_join can answer the query correctly.

This change attaches relation-implied predicates when generating MV scans, so predicates guaranteed by lower MV scans can participate in later nested MV matching and compensation.

@hello-stephen
Copy link
Copy Markdown
Contributor

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

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@foxtail463 foxtail463 changed the title Fix/nested mv relation implied predicates [fix](mv) Support relation implied predicates for nested MV rewrite May 25, 2026
@foxtail463
Copy link
Copy Markdown
Contributor Author

run buildall

@foxtail463 foxtail463 closed this May 25, 2026
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.

2 participants