lowka commented on code in PR #4522:
URL: https://github.com/apache/ignite-3/pull/4522#discussion_r1796622911


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/exp/agg/Accumulators.java:
##########
@@ -434,62 +490,76 @@ public RelDataType returnType(IgniteTypeFactory 
typeFactory) {
         }
     }
 
-    private static class Sum implements Accumulator {
+    /** Wraps another sum accumulator and returns {@code null} if there was 
updates. */
+    public static class Sum implements Accumulator {
         private Accumulator acc;
 
-        private boolean empty = true;
-
         public Sum(Accumulator acc) {
             this.acc = acc;
         }
 
         /** {@inheritDoc} */
-        @Override public void add(Object... args) {
+        @Override
+        public void add(AccumulatorsState state, Object... args) {
             if (args[0] == null) {
                 return;
             }
 
-            empty = false;
-            acc.add(args[0]);
+            acc.add(state, args);
         }
 
         /** {@inheritDoc} */
-        @Override public Object end() {
-            return empty ? null : acc.end();
+        @Override
+        public void end(AccumulatorsState state, AccumulatorsState result) {
+            if (!state.hasValue()) {
+                result.set(null);
+            } else {
+                result.set(state.get());

Review Comment:
   Fixed.



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