foxtail463 opened a new pull request, #63571:
URL: https://github.com/apache/doris/pull/63571

   Problem Summary:
   
   Nested MTMV rewrite can miss a valid rewrite because predicates implied by a 
lower MV scan are not carried into the upper MV rewrite context. When an upper 
MV is built on another MV, scanning the lower MV already guarantees its 
definition predicates, and those predicates should participate in upper MV 
matching and compensation.
   
   ```sql
   -- lower MV guarantees: sku_type = '1'
   CREATE MATERIALIZED VIEW mv_fact AS
   SELECT k1, dim_id, amount
   FROM fact
   WHERE sku_type = '1';
   
   -- upper MV is built on the lower MV
   CREATE MATERIALIZED VIEW mv_join AS
   SELECT f.k1, f.amount, d.tag
   FROM mv_fact f
   JOIN dim d ON f.dim_id = d.dim_id;
   
   -- query has the same predicate guaranteed by mv_fact
   SELECT f.k1, f.amount, d.tag
   FROM fact f
   JOIN dim d ON f.dim_id = d.dim_id
   WHERE f.sku_type = '1';
   ```
   
   mv_join is semantically built from rows that already satisfy fact.sku_type = 
'1'. If that relation-implied predicate is lost on the mv_fact scan inside 
mv_join, the optimizer may fail to prove that mv_join covers the query, so the 
nested MV rewrite is missed.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to