felipecrv commented on code in PR #43292:
URL: https://github.com/apache/arrow/pull/43292#discussion_r1689719319
##########
cpp/src/arrow/compute/kernels/vector_selection_test.cc:
##########
@@ -1363,177 +1626,184 @@ TEST_F(TestTakeKernel, Interval) {
this->TestNumericBasics(month_interval());
auto type = day_time_interval();
- CheckTake(type, "[[1, -600], [2, 3000], null]", "[0, null, 2, 1]",
- "[[1, -600], null, null, [2, 3000]]");
+ CheckTakeXA(type, "[[1, -600], [2, 3000], null]", "[0, null, 2, 1]",
+ "[[1, -600], null, null, [2, 3000]]");
type = month_day_nano_interval();
- CheckTake(type, "[[1, -2, 34567890123456789], [2, 3, -34567890123456789],
null]",
- "[0, null, 2, 1]",
- "[[1, -2, 34567890123456789], null, null, [2, 3,
-34567890123456789]]");
+ CheckTakeXA(type, "[[1, -2, 34567890123456789], [2, 3, -34567890123456789],
null]",
+ "[0, null, 2, 1]",
+ "[[1, -2, 34567890123456789], null, null, [2, 3,
-34567890123456789]]");
}
template <typename ArrowType>
-class TestTakeKernelWithNumeric : public TestTakeKernelTyped<ArrowType> {
- protected:
- void AssertTake(const std::string& values, const std::string& indices,
- const std::string& expected) {
- CheckTake(type_singleton(), values, indices, expected);
- }
-
- std::shared_ptr<DataType> type_singleton() {
- return TypeTraits<ArrowType>::type_singleton();
- }
-};
+class TestTakeKernelWithNumeric : public TestTakeKernelTyped<ArrowType> {};
TYPED_TEST_SUITE(TestTakeKernelWithNumeric, NumericArrowTypes);
TYPED_TEST(TestTakeKernelWithNumeric, TakeNumeric) {
- this->TestNumericBasics(this->type_singleton());
+ this->TestNumericBasics(this->value_type());
}
template <typename TypeClass>
class TestTakeKernelWithString : public TestTakeKernelTyped<TypeClass> {
public:
- std::shared_ptr<DataType> value_type() {
- return TypeTraits<TypeClass>::type_singleton();
- }
-
- void AssertTake(const std::string& values, const std::string& indices,
- const std::string& expected) {
- CheckTake(value_type(), values, indices, expected);
- }
-
- void AssertTakeDictionary(const std::string& dictionary_values,
- const std::string& dictionary_indices,
- const std::string& indices,
- const std::string& expected_indices) {
- auto dict = ArrayFromJSON(value_type(), dictionary_values);
- auto type = dictionary(int8(), value_type());
- ASSERT_OK_AND_ASSIGN(auto values,
- DictionaryArray::FromArrays(
- type, ArrayFromJSON(int8(), dictionary_indices),
dict));
- ASSERT_OK_AND_ASSIGN(
- auto expected,
- DictionaryArray::FromArrays(type, ArrayFromJSON(int8(),
expected_indices), dict));
- auto take_indices = ArrayFromJSON(int8(), indices);
- AssertTakeArrays(values, take_indices, expected);
+ void AssertTakeXADictionary(const std::string& dictionary_values,
+ const std::string& dictionary_indices,
+ const std::string& indices,
+ const std::string& expected_indices) {
+ return CheckTakeXADictionary(this->value_type(), dictionary_values,
+ dictionary_indices, indices,
expected_indices);
}
};
TYPED_TEST_SUITE(TestTakeKernelWithString, BaseBinaryArrowTypes);
TYPED_TEST(TestTakeKernelWithString, TakeString) {
- this->AssertTake(R"(["a", "b", "c"])", "[0, 1, 0]", R"(["a", "b", "a"])");
- this->AssertTake(R"([null, "b", "c"])", "[0, 1, 0]", "[null, \"b\", null]");
- this->AssertTake(R"(["a", "b", "c"])", "[null, 1, 0]", R"([null, "b",
"a"])");
+ this->CheckTakeXA(R"(["a", "b", "c"])", "[0, 1, 0]", R"(["a", "b", "a"])");
+ this->CheckTakeXA(R"([null, "b", "c"])", "[0, 1, 0]", "[null, \"b\", null]");
+ this->CheckTakeXA(R"(["a", "b", "c"])", "[null, 1, 0]", R"([null, "b",
"a"])");
- this->TestNoValidityBitmapButUnknownNullCount(this->value_type(), R"(["a",
"b", "c"])",
- "[0, 1, 0]");
+ this->TestNoValidityBitmapButUnknownNullCount(R"(["a", "b", "c"])", "[0, 1,
0]");
std::shared_ptr<DataType> type = this->value_type();
+ const std::string kABC = R"(["a", "b", "c"])";
Review Comment:
I didn't want to split the template-definition, test-suit macro and
typed-test instantiations with a small declaration like this one.
--
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]