MartijnVisser commented on code in PR #29373:
URL: https://github.com/apache/flink/pull/29373#discussion_r4205091953


##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/operators/over/NonTimeRowsUnboundedPrecedingFunction.java:
##########
@@ -402,19 +406,27 @@ private RowData getPreviousAccumulator(
      */
     private void reAccumulateIdsAndEmitUpdates(
             List<Long> ids, int removeIndex, Collector<RowData> out) throws 
Exception {
+        RowData baseAcc = aggFuncs.getAccumulators();
         for (int j = removeIndex; j < ids.size(); j++) {
             RowData value = valueMapState.get(ids.get(j));
             if (j == removeIndex) {
-                collectDelete(out, value, 
accMapState.get(GenericRowData.of(ids.get(j))));
+                RowData deletedAcc = 
accMapState.get(GenericRowData.of(ids.get(j)));
+                collectDelete(out, value, 
setAccumulatorAndGetValue(deletedAcc));
+                aggFuncs.setAccumulators(baseAcc);
             } else {
+                RowData prevAcc = 
accMapState.get(GenericRowData.of(ids.get(j)));
                 aggFuncs.accumulate(value);
+                RowData newAcc = aggFuncs.getAccumulators();
                 // Logic to early out
-                if 
(aggFuncs.getValue().equals(accMapState.get(GenericRowData.of(ids.get(j))))) {
+                if (newAcc.equals(prevAcc)) {
                     break;

Review Comment:
   With the FLINK-40735 equaliser here this also hits RocksDB: (10, p), (10, 
p), (10, q), (20, r), delete the first, and COUNT(DISTINCT v) for 20 is 2, not 
3. I'd fix it here.



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to