KeeProMise commented on code in PR #59594:
URL: https://github.com/apache/doris/pull/59594#discussion_r2666859454


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/AbstractMaterializedViewRule.java:
##########
@@ -371,7 +373,7 @@ protected List<Plan> doRewrite(StructInfo queryStructInfo, 
CascadesContext casca
                     return rewriteResults;
                 }
                 boolean partitionNeedUnion = 
PartitionCompensator.needUnionRewrite(invalidPartitions, cascadesContext);
-                boolean canUnionRewrite = canUnionRewrite(queryPlan,
+                canUnionRewrite = canUnionRewrite && canUnionRewrite(queryPlan,

Review Comment:
   > The current behavior is: when enable_materialized_view_union_rewrite = 
false, the system does not actively compensate for UNION ALL, and the rewrite 
succeeds. When enable_materialized_view_union_rewrite = true, but UNION ALL 
compensation fails, the rewrite will fail. I understand your requirement is 
that when enable_materialized_view_union_rewrite = false, the rewrite should 
also fail, is that correct? In what business scenarios would this be used?
   
   Hi @seawinde We encountered an issue when upgrading from version 3.0.6 to 
3.0.8: if a base table has 10 partitions but its materialized view only has 2 
partitions, the materialized view will still be used even when union rewrite is 
disabled, leading to inconsistent data reads. All our materialized views are 
external table materialized views (hence union rewrite is not enabled), yet 
this issue also exists with internal table materialized views. Setting aside 
the usage scenario, from a user perspective: if union rewrite is disabled, the 
rewrite should not succeed—because the materialized view only covers 2 
partitions, while the SELECT query requires accessing all partitions of the 
base table.



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