Github user fhueske commented on a diff in the pull request: https://github.com/apache/flink/pull/4355#discussion_r135561193 --- Diff: flink-libraries/flink-table/src/test/java/org/apache/flink/table/runtime/utils/JavaUserDefinedAggFunctions.java --- @@ -237,9 +248,13 @@ public void resetAccumulator(CountDistinctAccum acc) { //Overloaded retract method public void retract(CountDistinctAccum accumulator, long id) { try { - if (!accumulator.map.contains(String.valueOf(id))) { - accumulator.map.remove(String.valueOf(id)); - accumulator.count -= 1; + Integer cnt = accumulator.map.get(String.valueOf(id)); + if (cnt != null) { + cnt -= 1; + if (cnt <= 0) { + accumulator.map.remove(String.valueOf(id)); + accumulator.count -= 1; + } --- End diff -- We should update the count if it is > 0: ``` else { accumulator.map.put(String.valueOf(id), cnt) } ```
--- 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. ---