KurtYoung commented on a change in pull request #9966: [FLINK-14053] 
[blink-planner] DenseRankAggFunction.accumulateExpressions. it should be thinki…
URL: https://github.com/apache/flink/pull/9966#discussion_r337425773
 
 

 ##########
 File path: 
flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/functions/aggfunctions/DenseRankAggFunction.java
 ##########
 @@ -67,8 +65,8 @@ public DenseRankAggFunction(InternalType[] orderKeyTypes) {
        @Override
        public Expression[] accumulateExpressions() {
                Expression[] accExpressions = new Expression[1 + 
operands().length];
-               // sequence = if (lastValues equalTo orderKeys) sequence else 
sequence + 1
-               accExpressions[0] = ifThenElse(orderKeyEqualsExpression(), 
sequence, plus(sequence, literal(1L)));
+               // sequence = if (lastValues equalTo orderKeys and sequence != 
0) sequence else sequence + 1
+               accExpressions[0] = ifThenElse(and(orderKeyEqualsExpression(), 
not(equalTo(sequence, literal(0L)))), sequence, plus(sequence, literal(1L)));
 
 Review comment:
   inside `orderKeyEqualsExpression()`, we already compare the last_value with 
null which is the initial value. Why this conflicts with the order by key's 
value? Do you mean the order by key is null? 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to