XieJiann commented on code in PR #27051: URL: https://github.com/apache/doris/pull/27051#discussion_r1407395359
########## 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: Yeah, I forgot to delete loc 240. For 1, there may be a lot of functions, but I have not handled them systematically. May be we can do it later -- 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