Myasuka commented on a change in pull request #11482: [FLINK-16581][table]
Minibatch deduplication lack state TTL bug fix
URL: https://github.com/apache/flink/pull/11482#discussion_r400008749
##########
File path:
flink-table/flink-table-runtime-blink/src/test/java/org/apache/flink/table/runtime/operators/deduplicate/MiniBatchDeduplicateKeepFirstRowFunctionTest.java
##########
@@ -71,4 +71,41 @@ public void testKeepFirstRowWithGenerateRetraction() throws
Exception {
testHarness.close();
}
+ @Test
+ public void tesKeepFirstRowWithStateTtl() throws Exception{
+ MiniBatchDeduplicateKeepFirstRowFunction func = new
MiniBatchDeduplicateKeepFirstRowFunction(typeSerializer,
minTime.toMilliseconds());
+ OneInputStreamOperatorTestHarness<BaseRow, BaseRow> testHarness
= createTestHarness(func);
+ testHarness.setup();
+ testHarness.open();
+ testHarness.processElement(record("book", 1L, 12));
+ testHarness.processElement(record("book", 2L, 11));
+ // output is empty because bundle not trigger yet.
+ Assert.assertTrue(testHarness.getOutput().isEmpty());
+ testHarness.processElement(record("book", 1L, 13));
+
+ Thread.sleep(30);
Review comment:
Unfortunately, current we always use `TtlTimeProvider.DEFAULT` to create
keyed state backend. One way to walk around this:
1. Define a new `MockTtlTimeProvider` which could set current time outside.
1. Define a `TTLMemoryStateBackend` extended from `MemoryStateBackend` which
would ignore the given `TtlTimeProvider.DEFAULT` when creating keyed state
backend, but use previous newly defined `MockTtlTimeProvider`.
1. Set the `TTLMemoryStateBackend` to the newly
`KeyedOneInputStreamOperatorTestHarness` to use our customized state backend.
Then you could set a new time to `MockTtlTimeProvider` to ensure time has
passed time to live.
----------------------------------------------------------------
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