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

    https://github.com/apache/flink/pull/4279#discussion_r126535807
  
    --- Diff: 
flink-libraries/flink-table/src/test/scala/org/apache/flink/table/api/scala/stream/table/GroupAggregationsITCase.scala
 ---
    @@ -38,6 +38,43 @@ class GroupAggregationsITCase extends 
StreamingWithStateTestBase {
       private val queryConfig = new StreamQueryConfig()
       queryConfig.withIdleStateRetentionTime(Time.hours(1), Time.hours(2))
     
    +
    +  @Test
    +  def testDistinct(): Unit = {
    +    val env = StreamExecutionEnvironment.getExecutionEnvironment
    +    env.setStateBackend(getStateBackend)
    +    val tEnv = TableEnvironment.getTableEnvironment(env)
    +    StreamITCase.clear
    +
    +    val t = StreamTestData.get3TupleDataStream(env).toTable(tEnv, 'a, 'b, 
'c)
    +      .select('b).distinct()
    +
    +    val results = t.toRetractStream[Row](queryConfig)
    +    results.addSink(new StreamITCase.RetractingSink).setParallelism(1)
    +    env.execute()
    +
    +    val expected = mutable.MutableList("1", "2", "3", "4", "5", "6")
    +    assertEquals(expected.sorted, StreamITCase.retractedResults.sorted)
    +  }
    +
    +  @Test
    +  def testDistinctAfterAggregate(): Unit = {
    +    val env = StreamExecutionEnvironment.getExecutionEnvironment
    +    env.setStateBackend(getStateBackend)
    +    val tEnv = TableEnvironment.getTableEnvironment(env)
    +    StreamITCase.clear
    +
    +    val t = StreamTestData.get5TupleDataStream(env).toTable(tEnv, 'a, 'b, 
'c, 'd, 'e)
    +      .groupBy('a, 'e).select('e).distinct()
    --- End diff --
    
    I think it would be better if the first aggregation would produce updates, 
such as a `.groupBy('e).select('e, 'a.count()).distinct()`. The count 
aggregation will produce different count values which have to be retracted and 
accumulated.


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