aucahuasi commented on a change in pull request #11159:
URL: https://github.com/apache/arrow/pull/11159#discussion_r710220892



##########
File path: cpp/src/arrow/compute/kernels/scalar_nested_test.cc
##########
@@ -39,6 +39,46 @@ TEST(TestScalarNested, ListValueLength) {
   }
 }
 
+TEST(TestScalarNested, ListElement) {
+  for (auto ty : {list(int16()), fixed_size_list(uint8(), 2)}) {
+    auto input = ArrayFromJSON(ty, "[[8, 5], [74, 92], [7, 4]]");
+    auto out_ty = ty->id() == Type::LIST ? int16() : uint8();
+    auto expected = ArrayFromJSON(out_ty, "[5, 92, 4]");
+    auto index = ScalarFromJSON(int32(), "1");
+    CheckVectorBinary("list_element", input, Datum(index), expected);
+  }
+
+  for (auto ty : {fixed_size_list(float32(), 2), large_list(float64())}) {
+    auto input = ArrayFromJSON(ty, "[[8.0, 5.0], [74.0, 92.0], [7.0, 4.0]]");
+    auto out_ty = ty->id() == Type::FIXED_SIZE_LIST ? float32() : float64();
+    auto expected = ArrayFromJSON(out_ty, "[8, 74.0, 7.0]");
+    auto index = ScalarFromJSON(int64(), "0");
+    CheckVectorBinary("list_element", input, Datum(index), expected);
+  }
+
+  // Construct a list with a non-empty null slot
+  auto input = ArrayFromJSON(list(int16()), "[[0, null, 1], [0, 0], [2, 3], 
[4, 5]]");
+  TweakValidityBit(input, 1, false);
+  auto expected = ArrayFromJSON(int16(), "[null, 0, 3, 5]");
+  auto index = ScalarFromJSON(int32(), "1");
+  CheckVectorBinary("list_element", input, Datum(index), expected);
+}
+
+TEST(TestScalarNested, ListElementChunkedArray) {

Review comment:
       This is the code that is throwing that issue
   `CheckScalar("list_element", {input, Datum(index)}, expected);`
   cc @edponce @lidavidm 




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