Hi Fanbin, Thanks for reporting this. I think you are right, the implementation is not correct. I have created a JIRA issue [1] to fix this. Btw, the CountDistinctWithMerge in blink planner is implemented correctly [2].
Best, Jark [1]: https://issues.apache.org/jira/browse/FLINK-15979 [2]: https://github.com/apache/flink/blob/master/flink-table/flink-table-planner-blink/src/test/java/org/apache/flink/table/planner/plan/utils/JavaUserDefinedAggFunctions.java#L369 On Tue, 11 Feb 2020 at 03:36, Fanbin Bu <[email protected]> wrote: > Hi, > > For the following implementation of merge, > https://github.com/apache/flink/blob/0ab1549f52f1f544e8492757c6b0d562bf50a061/flink-table/flink-table-planner/src/test/java/org/apache/flink/table/runtime/utils/JavaUserDefinedAggFunctions.java#L224 > > what if acc has the some keys in mergeAcc? the merged count would not be > accurate then. I think the count should be incremented by one in > https://github.com/apache/flink/blob/0ab1549f52f1f544e8492757c6b0d562bf50a061/flink-table/flink-table-planner/src/test/java/org/apache/flink/table/runtime/utils/JavaUserDefinedAggFunctions.java#L236 > > > Thanks, > Fanbin > > >
