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


##########
cpp/src/arrow/compute/kernels/vector_cumulative_ops_test.cc:
##########
@@ -0,0 +1,183 @@
+// 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/compute/api.h"
+#include "arrow/compute/kernels/test_util.h"
+
+namespace arrow {
+namespace compute {
+
+class TestCumulativeOp : public ::testing::Test {
+ protected:
+  std::shared_ptr<Array> array(std::shared_ptr<DataType>& type,
+                               const std::string& values) {
+    return ArrayFromJSON(type, values);
+  }
+
+  std::shared_ptr<ChunkedArray> chunked_array(std::shared_ptr<DataType>& type,
+                                              const std::vector<std::string>& 
values) {
+    return ChunkedArrayFromJSON(type, values);
+  }
+
+  template <typename OptionsType>
+  void Assert(const std::string func, const std::shared_ptr<Array>& input,
+              const std::shared_ptr<Array>& expected, const OptionsType& 
options) {
+    ASSERT_OK_AND_ASSIGN(auto result, CallFunction(func, {Datum(input)}, 
&options));
+
+    AssertArraysApproxEqual(*expected, *result.make_array(), false,
+                            EqualOptions::Defaults());
+  }
+
+  template <typename OptionsType>
+  void Assert(std::shared_ptr<DataType>& type, const std::string func,
+              const std::shared_ptr<ChunkedArray>& input,
+              const std::shared_ptr<ChunkedArray>& expected, const 
OptionsType& options) {
+    ASSERT_OK_AND_ASSIGN(auto result,
+                         CallFunction(func, {Datum(input)}, &options, 
nullptr));
+
+    ChunkedArray actual(result.chunks(), type);
+    AssertChunkedApproxEquivalent(*expected, actual, EqualOptions::Defaults());
+  }
+};
+
+struct CumulativeSumParam {
+  std::string start;
+  bool skip_nulls;
+  std::shared_ptr<DataType> type;
+  std::string json_arrays_input_no_nulls;
+  std::string json_arrays_expected_no_nulls;
+  std::string json_arrays_input_with_nulls;
+  std::string json_arrays_expected_with_nulls;
+  std::vector<std::string> json_chunked_arrays_input_no_nulls;
+  std::vector<std::string> json_chunked_arrays_expected_no_nulls;
+  std::vector<std::string> json_chunked_arrays_input_with_nulls;
+  std::vector<std::string> json_chunked_arrays_expected_with_nulls;
+};
+
+std::vector<CumulativeSumParam> GenerateCumulativeSumParams(
+    std::string start, bool skip_nulls, std::string json_arrays_input_no_nulls,
+    std::string json_arrays_expected_no_nulls, std::string 
json_arrays_input_with_nulls,
+    std::string json_arrays_expected_with_nulls,
+    std::vector<std::string> json_chunked_arrays_input_no_nulls,
+    std::vector<std::string> json_chunked_arrays_expected_no_nulls,
+    std::vector<std::string> json_chunked_arrays_input_with_nulls,
+    std::vector<std::string> json_chunked_arrays_expected_with_nulls) {
+  std::vector<CumulativeSumParam> param_vector;
+
+  for (auto ty : NumericTypes()) {
+    param_vector.push_back(
+        {start, skip_nulls, ty, json_arrays_input_no_nulls, 
json_arrays_expected_no_nulls,
+         json_arrays_input_with_nulls, json_arrays_expected_with_nulls,
+         json_chunked_arrays_input_no_nulls, 
json_chunked_arrays_expected_no_nulls,
+         json_chunked_arrays_input_with_nulls, 
json_chunked_arrays_expected_with_nulls});
+  }
+
+  return param_vector;
+}

Review Comment:
   The issue is that Value-Parameterized tests run all test functions for a 
given test suite with using the same data for each functions, so all the data 
needed for input/expected are needed up front for test instantiation.
   
   To cut down on the size of the test parameter, we could provide only the 
array input/expected values and create the data for chunked arrays from those 
values within the test function (the values for the arrays and chunked arrays 
are the same, just in different shapes).



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