Github user fhueske commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4157#discussion_r125322758
  
    --- Diff: 
flink-libraries/flink-table/src/test/scala/org/apache/flink/table/runtime/harness/NonWindowHarnessTest.scala
 ---
    @@ -80,18 +80,79 @@ class NonWindowHarnessTest extends HarnessTestBase {
     
         val expectedOutput = new ConcurrentLinkedQueue[Object]()
     
    -    expectedOutput.add(new StreamRecord(CRow(Row.of(1L: JLong, 1: JInt), 
true), 1))
    -    expectedOutput.add(new StreamRecord(CRow(Row.of(2L: JLong, 1: JInt), 
true), 1))
    -    expectedOutput.add(new StreamRecord(CRow(Row.of(3L: JLong, 3: JInt), 
true), 1))
    -    expectedOutput.add(new StreamRecord(CRow(Row.of(4L: JLong, 6: JInt), 
true), 1))
    -    expectedOutput.add(new StreamRecord(CRow(Row.of(5L: JLong, 10: JInt), 
true), 1))
    -    expectedOutput.add(new StreamRecord(CRow(Row.of(6L: JLong, 3: JInt), 
true), 1))
    -    expectedOutput.add(new StreamRecord(CRow(Row.of(7L: JLong, 5: JInt), 
true), 1))
    -    expectedOutput.add(new StreamRecord(CRow(Row.of(8L: JLong, 11: JInt), 
true), 1))
    -    expectedOutput.add(new StreamRecord(CRow(Row.of(9L: JLong, 18: JInt), 
true), 1))
    -    expectedOutput.add(new StreamRecord(CRow(Row.of(10L: JLong, 3: JInt), 
true), 1))
    -
    -    verify(expectedOutput, result, new RowResultSortComparator(6))
    +    expectedOutput.add(new StreamRecord(CRow(Row.of(1L: JLong, "aaa", 1: 
JInt), true), 1))
    +    expectedOutput.add(new StreamRecord(CRow(Row.of(2L: JLong, "bbb", 1: 
JInt), true), 1))
    +    expectedOutput.add(new StreamRecord(CRow(Row.of(3L: JLong, "aaa", 3: 
JInt), true), 1))
    +    expectedOutput.add(new StreamRecord(CRow(Row.of(4L: JLong, "aaa", 6: 
JInt), true), 1))
    +    expectedOutput.add(new StreamRecord(CRow(Row.of(5L: JLong, "aaa", 10: 
JInt), true), 1))
    +    expectedOutput.add(new StreamRecord(CRow(Row.of(6L: JLong, "bbb", 3: 
JInt), true), 1))
    +    expectedOutput.add(new StreamRecord(CRow(Row.of(7L: JLong, "aaa", 5: 
JInt), true), 1))
    +    expectedOutput.add(new StreamRecord(CRow(Row.of(8L: JLong, "aaa", 11: 
JInt), true), 1))
    +    expectedOutput.add(new StreamRecord(CRow(Row.of(9L: JLong, "aaa", 18: 
JInt), true), 1))
    +    expectedOutput.add(new StreamRecord(CRow(Row.of(10L: JLong, "bbb", 3: 
JInt), true), 1))
    +
    +    verifySorted(expectedOutput, result, new RowResultSortComparator)
    +
    +    testHarness.close()
    +  }
    +
    +  @Test
    +  def testProcTimeNonWindowWithUpdateInterval(): Unit = {
    +
    +    val processFunction = new KeyedProcessOperator[String, CRow, CRow](
    +      new GroupAggProcessFunctionWithUpdateInterval(
    +        genSumAggFunction,
    +        sumAggregationStateType,
    +        sumAggregationRowType,
    +        false,
    +        queryConfig
    +        .withIdleStateRetentionTime(Time.seconds(4), Time.seconds(5))
    +        .withUnboundedAggregateUpdateInterval(Time.seconds(1))))
    +
    +    val testHarness =
    +      createHarnessTester(
    +        processFunction,
    +        new TupleRowKeySelector[String](2),
    +        BasicTypeInfo.STRING_TYPE_INFO)
    +
    +    testHarness.open()
    +
    +    testHarness.setProcessingTime(1)
    +
    +    testHarness.processElement(new StreamRecord(CRow(Row.of(1L: JLong, 1: 
JInt, "aaa"), true), 1))
    +    testHarness.processElement(new StreamRecord(CRow(Row.of(2L: JLong, 1: 
JInt, "bbb"), true), 1))
    +    testHarness.setProcessingTime(1000)
    +    testHarness.processElement(new StreamRecord(CRow(Row.of(3L: JLong, 2: 
JInt, "aaa"), true), 1))
    +    testHarness.processElement(new StreamRecord(CRow(Row.of(4L: JLong, 3: 
JInt, "aaa"), true), 1))
    +
    +    testHarness.setProcessingTime(1002)
    +    testHarness.processElement(new StreamRecord(CRow(Row.of(5L: JLong, 4: 
JInt, "aaa"), true), 1))
    +    testHarness.processElement(new StreamRecord(CRow(Row.of(6L: JLong, 2: 
JInt, "bbb"), true), 1))
    +
    +    testHarness.setProcessingTime(4003)
    +    testHarness.processElement(new StreamRecord(CRow(Row.of(7L: JLong, 5: 
JInt, "aaa"), true), 1))
    +    testHarness.processElement(new StreamRecord(CRow(Row.of(8L: JLong, 6: 
JInt, "aaa"), true), 1))
    +
    +    // clear all states
    +    testHarness.setProcessingTime(10003)
    +    testHarness.processElement(new StreamRecord(CRow(Row.of(9L: JLong, 7: 
JInt, "aaa"), true), 1))
    +    testHarness.processElement(new StreamRecord(CRow(Row.of(10L: JLong, 3: 
JInt, "bbb"), true), 1))
    +
    +    testHarness.setProcessingTime(12003)
    +
    +    val result = testHarness.getOutput
    +
    +    val expectedOutput = new ConcurrentLinkedQueue[Object]()
    +
    +    expectedOutput.add(new StreamRecord(CRow(Row.of(1L: JLong, "aaa", 6: 
JInt), true), 1001))
    --- End diff --
    
    The `ProcessingFunction` sets the timestamp of the processing time timer as 
event-time to all records emitted in `onTimer()`. IMO, this is pretty bad 
behavior because processing time and event time (and existing watermarks) are 
not related at all. I think the best behavior would be to assign the timestamp 
of the last updating record. However, this would again require to hold back 
watermarks which is not trivial (and can only be done with a custom operator).
    
    For now, I would propose to set the current watermark as timestamp such 
that records are not considered as late data. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to