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

   ### What problem does this PR solve?
   
   Problem Summary:
   
   Constraint changes can change MV rewrite eligibility, especially for 
PK/FK/UK-based reasoning.
   
   Example:
   
       -- MV
       SELECT o.o_orderkey
       FROM orders o
       INNER JOIN lineitem l
         ON o.o_orderkey = l.l_orderkey
   
   Without the relevant PK/FK metadata, the rewrite may fail.
   
   After:
   
       ALTER TABLE lineitem ADD CONSTRAINT lineitem_pk PRIMARY KEY (l_orderkey);
       ALTER TABLE orders ADD CONSTRAINT orders_fk
           FOREIGN KEY (o_orderkey) REFERENCES lineitem(l_orderkey);
   
   the same query may become rewritable because the optimizer can prove the 
join relationship through constraints.
   
   After dropping either the FK or the referenced PK, that reasoning is no 
longer valid, so the rewrite should stop again.
   
   This patch invalidates dependent MTMV rewrite caches after ADD/DROP 
CONSTRAINT. The invalidation is driven by the analyzed table name and affected 
base-table infos, so it does not depend on rewrite cache contents that may have 
been built from old constraint metadata.
   
   It also prevents an in-flight rewrite cache built before the constraint 
change from being published after invalidation, avoiding stale PK/FK/UK 
metadata from being reused by later rewrites.


-- 
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