xzj7019 commented on code in PR #27051:
URL: https://github.com/apache/doris/pull/27051#discussion_r1407389082


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalWindow.java:
##########
@@ -224,4 +227,52 @@ public Optional<Plan> pushPartitionLimitThroughWindow(long 
partitionLimit, boole
 
         return Optional.ofNullable(window);
     }
+
+    private void updateFuncDepsByWindowExpr(NamedExpression namedExpression, 
FunctionalDependencies.Builder builder) {
+        if (namedExpression.children().size() != 1 || 
!(namedExpression.child(0) instanceof WindowExpression)) {
+            return;
+        }
+        WindowExpression windowExpr = (WindowExpression) 
namedExpression.child(0);
+        List<Expression> partitionKeys = windowExpr.getPartitionKeys();
+
+        // window func should return unique results for different rows
+        if (!(windowExpr.getFunction() instanceof RowNumber
+                || windowExpr.getFunction() instanceof Rank)) {
+            return;
+        }
+
+        // Now we only support slot type keys
+        if (!partitionKeys.stream().allMatch(Slot.class::isInstance)) {
+            return;
+        }
+        ImmutableSet<Slot> slotSet = partitionKeys.stream()
+                .map(s -> (Slot) s)
+                .collect(ImmutableSet.toImmutableSet());
+
+        // if partition by keys are unique, output is uniform
+        if 
(child(0).getLogicalProperties().getFunctionalDependencies().isUniqueAndNotNull(slotSet))
 {
+            if (windowExpr.getFunction() instanceof RowNumber
+                    || windowExpr.getFunction() instanceof Rank
+                    || windowExpr.getFunction() instanceof DenseRank) {

Review Comment:
   1. for unique and not null, i think the function list is not limited for 
those three, may be more...
   2. DenseRank is not allowed at line 240 before.



-- 
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: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to