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

   dependent mtmv caches on constraint changes
   
   MV rewrite could fail when the query used fewer joins than the MV If the 
eliminable extra join node carried a filter edge (system delete-sign filter or 
an ON-clause lifted filter), rewrite was rejected early with graph-node 
mismatch before semantic elimination checks. Remove that hard precheck so join 
elimination is decided by canEliminateViewEdge semantics.
   
   Also clear caches of MTMVs that depend on the altered base table when 
ADD/DROP CONSTRAINT runs, and fail the DDL if cache invalidation fails. This 
ensures newly added or removed unique/fk traits are immediately visible to 
rewrite and avoids stale StructInfo/DataTrait decisions.
   
   ### What problem does this PR solve?
   
   Issue Number: close #xxx
   
   Related PR: #xxx
   
   Problem Summary:
   
   ### Release note
   
   create database if not exists test;
   use test;
   
   drop table if exists t1;
   CREATE TABLE t1 (
       id INT,
       name VARCHAR(50)
   )
   DUPLICATE KEY(id)
   DISTRIBUTED BY HASH(id) BUCKETS 1
   PROPERTIES("replication_num" = "1");
   
   drop table if exists t2;
   CREATE TABLE t2 (
       id INT,
       value INT
   )
   UNIQUE KEY(id)
   DISTRIBUTED BY HASH(id) BUCKETS 1
   PROPERTIES(
       "replication_num" = "1",
       "enable_unique_key_merge_on_write" = "true"
   );
   
   ALTER TABLE t2 ADD CONSTRAINT uk_id UNIQUE (id);
   
   INSERT INTO t1 (id, name) VALUES 
   (1, 'Alice'),
   (2, 'Bob'),
   (3, 'Charlie');
   
   INSERT INTO t2 (id, value) VALUES 
   (1, 10),   -- 满足 t1.id = t2.id 且 value > 0
   (2, -5),   -- 满足 t1.id = t2.id,但不满足 value > 0
   (4, 20);   -- t2 独有的数据,t1 中没有
   
   
   DROP MATERIALIZED VIEW IF EXISTS mv_join_elimination;
   CREATE MATERIALIZED VIEW mv_join_elimination
   BUILD IMMEDIATE REFRESH COMPLETE ON MANUAL
   DISTRIBUTED BY HASH(id) BUCKETS 1
   PROPERTIES ('replication_num' = '1')
   AS
   SELECT 
       t1.id, 
       t1.name
   FROM t1
   LEFT JOIN t2 
       ON t1.id = t2.id AND t2.value > 0;
   
   explain SELECT id, name FROM t1;
   
   ### Check List (For Author)
   
   - Test <!-- At least one of them must be included. -->
       - [ ] Regression test
       - [ ] Unit Test
       - [ ] Manual test (add detailed scripts or steps below)
       - [ ] No need to test or manual test. Explain why:
           - [ ] This is a refactor/code format and no logic has been changed.
           - [ ] Previous test can cover this change.
           - [ ] No code files have been changed.
           - [ ] Other reason <!-- Add your reason?  -->
   
   - Behavior changed:
       - [ ] No.
       - [ ] Yes. <!-- Explain the behavior change -->
   
   - Does this need documentation?
       - [ ] No.
       - [ ] Yes. <!-- Add document PR link here. eg: 
https://github.com/apache/doris-website/pull/1214 -->
   
   ### Check List (For Reviewer who merge this PR)
   
   - [ ] Confirm the release note
   - [ ] Confirm test cases
   - [ ] Confirm document
   - [ ] Add branch pick label <!-- Add branch pick label that this PR should 
merge into -->
   
   


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