wuchong commented on a change in pull request #9741: [FLINK-14119][table] Clean 
idle state for RetractableTopNFunction
URL: https://github.com/apache/flink/pull/9741#discussion_r326939689
 
 

 ##########
 File path: 
flink-table/flink-table-runtime-blink/src/test/java/org/apache/flink/table/runtime/operators/rank/RetractableTopNFunctionTest.java
 ##########
 @@ -219,4 +219,38 @@ public void testDisableGenerateRetraction() throws 
Exception {
                                .assertOutputEqualsSorted("output wrong.", 
expectedOutput, testHarness.getOutput());
        }
 
+       @Test
+       public void testCleanIdleState() throws Exception {
+               AbstractTopNFunction func = createFunction(RankType.ROW_NUMBER, 
new ConstantRankRange(1, 2), true,
+                       true);
+               OneInputStreamOperatorTestHarness<BaseRow, BaseRow> testHarness 
= createTestHarness(func);
+               testHarness.open();
+
+               testHarness.processElement(record("book", 1L, 12));
+               testHarness.processElement(retractRecord("book", 1L, 12));
+               testHarness.processElement(record("fruit", 4L, 33));
+               testHarness.processElement(record("book", 2L, 19));
+               testHarness.processElement(record("fruit", 3L, 22));
+               testHarness.processElement(record("fruit", 5L, 43));
+
+               // cleanup state explicitly
+               func.onTimer(System.currentTimeMillis(), null, null);
+               testHarness.processElement(record("book", 4L, 11));
+               testHarness.processElement(record("fruit", 5L, 43));
+               testHarness.close();
+
+               List<Object> expectedOutput = new ArrayList<>();
+               expectedOutput.add(record("book", 1L, 12, 1L));
+               expectedOutput.add(deleteRecord("book", 1L, 12, 1L));
+               expectedOutput.add(record("fruit", 4L, 33, 1L));
+               expectedOutput.add(record("book", 2L, 19, 1L));
+               expectedOutput.add(deleteRecord("fruit", 4L, 33, 1L));
+               expectedOutput.add(record("fruit", 3L, 22, 1L));
+               expectedOutput.add(record("fruit", 4L, 33, 2L));
+               expectedOutput.add(deleteRecord("book", 2L, 19, 1L));
+               expectedOutput.add(record("book", 2L, 19, 2L));
+               expectedOutput.add(record("book", 4L, 11, 1L));
 
 Review comment:
   Add a comment above this line `// after state expiration`

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to