xzj7019 commented on code in PR #27051:
URL: https://github.com/apache/doris/pull/27051#discussion_r1406084761
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalWindow.java:
##########
@@ -224,4 +227,46 @@ 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))
{
Review Comment:
this is ok for rank
--
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]