rionmonster commented on code in PR #30245:
URL: https://github.com/apache/flink/pull/30245#discussion_r4775068919


##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/functions/aggfunctions/RankLikeAggFunctionBase.java:
##########
@@ -103,48 +99,7 @@ protected Expression orderKeyEqualsExpression() {
     }
 
     protected Expression generateInitLiteral(LogicalType orderType) {
-        Object value;
-        switch (orderType.getTypeRoot()) {
-            case BOOLEAN:
-                value = false;
-                break;
-            case TINYINT:
-                value = (byte) 0;
-                break;
-            case SMALLINT:
-                value = (short) 0;
-                break;
-            case INTEGER:
-                value = 0;
-                break;
-            case BIGINT:
-                value = 0L;
-                break;
-            case FLOAT:
-                value = 0.0f;
-                break;
-            case DOUBLE:
-                value = 0.0d;
-                break;
-            case DECIMAL:
-                value = BigDecimal.ZERO;
-                break;
-            case CHAR:
-            case VARCHAR:
-                value = "";
-                break;
-            case DATE:
-                value = LocalDateSerializer.INSTANCE.createInstance();
-                break;
-            case TIME_WITHOUT_TIME_ZONE:
-                value = LocalTimeSerializer.INSTANCE.createInstance();
-                break;
-            case TIMESTAMP_WITHOUT_TIME_ZONE:
-                value = LocalDateTimeSerializer.INSTANCE.createInstance();
-                break;
-            default:
-                throw new TableException("Unsupported type: " + orderType);
-        }
-        return valueLiteral(value, 
fromLogicalTypeToDataType(orderType).notNull());
+        // never compared: the first row of a partition always starts a new 
rank
+        return nullOf(fromLogicalTypeToDataType(orderType));

Review Comment:
   Good catch here and I've moved the null guard into its own separate commit 
(in 75a72ce930c) just ahead of the rank fix.



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

Reply via email to