pitrou commented on a change in pull request #10606:
URL: https://github.com/apache/arrow/pull/10606#discussion_r660750124



##########
File path: cpp/src/arrow/compute/kernels/vector_selection_test.cc
##########
@@ -1279,6 +1279,58 @@ TEST_F(TestTakeKernelWithStruct, TakeStruct) {
       struct_type, R"([{"a": 1}, {"a": 2, "b": "hello"}])", "[0, 1, 0]");
 }
 
+class TestTakeKernelWithDenseUnion : public 
TestTakeKernelTyped<DenseUnionType> {
+ public:
+  void AssertTake(const std::shared_ptr<DataType>& type, const std::string& 
values,
+                  const std::string& indices, const std::string& type_codes,
+                  const std::string& value_offsets) {
+    auto union_array =
+        std::static_pointer_cast<DenseUnionArray>(ArrayFromJSON(type, values));
+    ArrayVector children;
+    children.reserve(type->num_fields());
+    std::vector<std::string> field_names;
+    field_names.reserve(type->num_fields());
+    for (int i = 0; i < type->num_fields(); i++) {
+      children.push_back(union_array->field(i));
+      field_names.push_back(type->field(i)->name());
+    }
+    ASSIGN_OR_ABORT(
+        std::shared_ptr<Array> expected,
+        DenseUnionArray::Make(*ArrayFromJSON(int8(), type_codes),
+                              *ArrayFromJSON(int32(), value_offsets), children,
+                              field_names, 
union_array->union_type()->type_codes()));
+
+    std::shared_ptr<Array> actual;
+
+    for (auto index_type : {int8(), uint32()}) {
+      ASSERT_OK(TakeJSON(type, values, index_type, indices, &actual));
+      ASSERT_OK(actual->Validate());
+      AssertArraysEqual(*expected, *actual, /*verbose=*/true);
+    }
+  }
+};
+
+TEST_F(TestTakeKernelWithDenseUnion, TakeDenseUnion) {
+  auto union_type = dense_union({field("a", int32()), field("b", utf8())}, {2, 
5});

Review comment:
       Not sure why you're not reusing the test code from `DISABLED_TakeUnion` 
below? The example results seem different.




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