github-actions[bot] commented on code in PR #59972:
URL: https://github.com/apache/doris/pull/59972#discussion_r3683774230


##########
fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVRelatedPartitionDescOnePartitionColGenerator.java:
##########
@@ -49,16 +49,22 @@ public class 
MTMVRelatedPartitionDescOnePartitionColGenerator implements MTMVRel
 
     @Override
     public void apply(MTMVPartitionInfo mvPartitionInfo, Map<String, String> 
mvProperties,
-            RelatedPartitionDescResult lastResult, List<Column> 
partitionColumns) throws AnalysisException {
+            RelatedPartitionDescResult lastResult, List<Column> 
partitionColumns,
+                      Map<List<String>, Set<String>> queryUsedPartitionMap) 
throws AnalysisException {
         if (mvPartitionInfo.getPartitionType() == 
MTMVPartitionType.SELF_MANAGE) {
             return;
         }
         Map<MTMVRelatedTableIf, Map<PartitionKeyDesc, Set<String>>> res = 
Maps.newHashMap();
+        // the key is mv related table, the value is map<partition name, 
partition item>
         Map<MTMVRelatedTableIf, Map<String, PartitionItem>> 
relatedPartitionItems = lastResult.getItems();
         for (Entry<MTMVRelatedTableIf, Map<String, PartitionItem>> entry : 
relatedPartitionItems.entrySet()) {
             int relatedColPos = mvPartitionInfo.getPctColPos(entry.getKey());
             Map<PartitionKeyDesc, Set<String>> onePctRes = Maps.newHashMap();
+            Set<String> queryUsedPartitions = 
queryUsedPartitionMap.get(entry.getKey().getFullQualifiers());
             for (Entry<String, PartitionItem> onePctEntry : 
entry.getValue().entrySet()) {
+                if (queryUsedPartitions != null && 
!queryUsedPartitions.contains(onePctEntry.getKey())) {

Review Comment:
   [P1] Preserve complete FOLLOW_BASE_TABLE bucket mappings
   
   A selected physical partition does not necessarily correspond one-to-one 
with an MV partition. For the supported `LIST(c1,c2)` case in this test suite, 
`p1_bj` and `p1_sh` both project to the `c1 = 1` MV partition. Filtering here 
to only `p1_bj` makes the rewrite-time mapping `{p1_bj}`, while an unfiltered 
refresh records `{p1_bj,p1_sh}` for that MV partition; `isSyncWithPartitions()` 
requires exact set equality, so the otherwise current MV is rejected for 
queries pruned to `p1_bj`. Please expand `FOLLOW_BASE_TABLE` filters to all 
physical partitions that project to each selected MV descriptor (as the EXPR 
path already expands to MV granularity), and cover the freshness/rewrite path 
rather than asserting the incomplete local set.



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