JabariBooker commented on code in PR #12460:
URL: https://github.com/apache/arrow/pull/12460#discussion_r874156305


##########
cpp/src/arrow/compute/kernels/vector_cumulative_ops_test.cc:
##########
@@ -0,0 +1,314 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include <memory>
+#include <string>
+#include <vector>
+
+#include <gtest/gtest.h>
+
+#include "arrow/array.h"
+#include "arrow/chunked_array.h"
+#include "arrow/testing/gtest_util.h"
+#include "arrow/testing/util.h"
+#include "arrow/type.h"
+
+#include "arrow/array/builder_primitive.h"
+#include "arrow/compute/api.h"
+#include "arrow/compute/kernels/test_util.h"
+
+namespace arrow {
+namespace compute {
+
+TEST(TestCumulativeSum, Empty) {
+  CumulativeSumOptions options;
+  for (auto ty : NumericTypes()) {
+    auto empty_arr = ArrayFromJSON(ty, "[]");
+    auto empty_chunked = ChunkedArrayFromJSON(ty, {"[]"});
+    CheckVectorUnary("cumulative_sum", empty_arr, empty_arr, &options);
+    CheckVectorUnary("cumulative_sum_checked", empty_arr, empty_arr, &options);
+
+    CheckVectorUnary("cumulative_sum", empty_chunked, empty_chunked, &options);
+    CheckVectorUnary("cumulative_sum_checked", empty_chunked, empty_chunked, 
&options);
+  }
+}
+
+TEST(TestCumulativeSum, AllNulls) {
+  CumulativeSumOptions options;
+  for (auto ty : NumericTypes()) {
+    auto nulls_arr = ArrayFromJSON(ty, "[null, null, null]");
+    auto nulls_one_chunk = ChunkedArrayFromJSON(ty, {"[null, null, null]"});
+    auto nulls_three_chunks = ChunkedArrayFromJSON(ty, {"[null]", "[null]", 
"[null]"});
+    CheckVectorUnary("cumulative_sum", nulls_arr, nulls_arr, &options);
+    CheckVectorUnary("cumulative_sum_checked", nulls_arr, nulls_arr, &options);
+
+    CheckVectorUnary("cumulative_sum", nulls_one_chunk, nulls_one_chunk, 
&options);
+    CheckVectorUnary("cumulative_sum_checked", nulls_one_chunk, 
nulls_one_chunk,
+                     &options);
+
+    CheckVectorUnary("cumulative_sum", nulls_three_chunks, nulls_one_chunk, 
&options);
+    CheckVectorUnary("cumulative_sum_checked", nulls_three_chunks, 
nulls_one_chunk,
+                     &options);
+  }
+}
+
+TEST(TestCumulativeSum, ScalarInput) {
+  CumulativeSumOptions no_start;
+  CumulativeSumOptions with_start(10);
+  for (auto ty : NumericTypes()) {
+    CheckVectorUnary("cumulative_sum", ScalarFromJSON(ty, "10"),
+                     ArrayFromJSON(ty, "[10]"), &no_start);
+    CheckVectorUnary("cumulative_sum_checked", ScalarFromJSON(ty, "10"),
+                     ArrayFromJSON(ty, "[10]"), &no_start);
+
+    CheckVectorUnary("cumulative_sum", ScalarFromJSON(ty, "10"),
+                     ArrayFromJSON(ty, "[20]"), &with_start);
+    CheckVectorUnary("cumulative_sum_checked", ScalarFromJSON(ty, "10"),
+                     ArrayFromJSON(ty, "[20]"), &with_start);
+  }

Review Comment:
   NullType is not support. So, we can test ensure that that it returns the 
proper error, or we could trivially process the cumulative sum for NullType 
inputs (e.g. NullScalar inputs produces a NullScalar, similar for arrays and 
chunked arrays)



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