morrySnow commented on code in PR #65393:
URL: https://github.com/apache/doris/pull/65393#discussion_r3644956522


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/PartitionIncrementMaintainer.java:
##########
@@ -476,25 +498,41 @@ private boolean checkWindowPartition(Expression 
expression, PartitionIncrementCh
                     expression.collectToList(expressionTreeNode -> 
expressionTreeNode instanceof WindowExpression);
             for (Object windowExpressionObj : windowExpressions) {
                 WindowExpression windowExpression = (WindowExpression) 
windowExpressionObj;
-                List<Expression> partitionKeys = 
windowExpression.getPartitionKeys();
-                Set<Column> originalPartitionbyExprSet = new HashSet<>();
-                partitionKeys.forEach(groupExpr -> {
-                    if (groupExpr instanceof SlotReference && 
groupExpr.isColumnFromTable()) {
-                        originalPartitionbyExprSet.add(((SlotReference) 
groupExpr).getOriginalColumn().get());
-                    }
-                });
-                Set<SlotReference> contextPartitionColumnSet = 
getPartitionColumnsToCheck(context);
-                if (contextPartitionColumnSet.isEmpty()) {
-                    return false;
-                }
-                if (contextPartitionColumnSet.stream().noneMatch(
-                        partition -> 
originalPartitionbyExprSet.contains(partition.getOriginalColumn().get()))) {
+                if 
(!checkPartitionKeysContainPartitionToCheck(windowExpression.getPartitionKeys(),
 context)) {
                     return false;
                 }
             }
             return true;
         }
 
+        private boolean 
checkPartitionKeysContainPartitionToCheck(List<Expression> partitionKeys,
+                PartitionIncrementCheckContext context) {
+            Set<Column> originalPartitionByExprSet = new HashSet<>();
+            partitionKeys.forEach(partitionKey -> {
+                if (partitionKey instanceof SlotReference && 
partitionKey.isColumnFromTable()) {
+                    originalPartitionByExprSet.add(((SlotReference) 
partitionKey).getOriginalColumn().get());
+                }
+            });
+            Set<SlotReference> contextPartitionColumnSet = 
getPartitionColumnsToCheck(context);
+            if (contextPartitionColumnSet.isEmpty()) {
+                return false;
+            }
+            return contextPartitionColumnSet.stream().anyMatch(
+                    partition -> 
originalPartitionByExprSet.contains(partition.getOriginalColumn().get()));
+        }
+
+        private boolean planOutputContainsPartitionColumnToCheck(Plan plan, 
PartitionIncrementCheckContext context) {
+            Set<Slot> outputSet = plan.getOutputSet();
+            for (NamedExpression namedExpression : 
context.getPartitionAndRefExpressionMap().keySet()) {
+                // Plan outputs are slots, so only tracked partition 
expressions already resolved
+                // to slots can match here.
+                if (namedExpression instanceof Slot && 
outputSet.contains(namedExpression)) {
+                    return true;

Review Comment:
   这里可能得反过来,因为我看 namedExpression 这个可以不是 slot,那么如果这个时候返回false,是不是就有可能跳过必要的检查呀?



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