tsreaper commented on a change in pull request #17570:
URL: https://github.com/apache/flink/pull/17570#discussion_r737099501



##########
File path: 
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/operators/rank/RetractableTopNFunction.java
##########
@@ -455,9 +464,18 @@ private boolean retractRecordWithoutRowNumber(
                     // sends the record if there is a record recently upgrades 
to Top-N
                     int index = Long.valueOf(rankEnd - nextRank).intValue();
                     List<RowData> inputs = dataState.get(key);
-                    RowData toAdd = inputs.get(index);
-                    collectInsert(out, toAdd);
-                    break;
+                    if (inputs == null) {
+                        // Skip the data if it's state is cleared because of 
state ttl.
+                        if (lenient) {
+                            LOG.warn(STATE_CLEARED_WARN_MSG);
+                        } else {
+                            throw new RuntimeException(STATE_CLEARED_WARN_MSG);
+                        }
+                    } else {
+                        RowData toAdd = inputs.get(index);
+                        collectInsert(out, toAdd);
+                        break;

Review comment:
       OK I understand. When we discover that records of this sort key do not 
exist in states, we should just skip this sort key as if nothing happens and 
continue processing. So we should only break out of the loop here.




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