wjones127 commented on code in PR #15210:
URL: https://github.com/apache/arrow/pull/15210#discussion_r1064886810


##########
cpp/src/arrow/array/array_list_test.cc:
##########
@@ -509,6 +509,18 @@ class TestListArray : public ::testing::Test {
     ASSERT_RAISES(Invalid, ValidateOffsets(2, {0, 7, 4}, values));
   }
 
+  void TestSliced() {
+    auto arr = ArrayFromJSON(list(int16()), "[[1, 2], [3, 4, 5], [6], [7, 
8]]");
+
+    auto arr_sliced = arr->Slice(0, 2);
+    auto expected_sliced = ArrayFromJSON(list(int16()), "[[1, 2], [3, 4, 5]]");
+    AssertArraysEqual(*expected_sliced, *arr_sliced);
+
+    auto values = checked_cast<ListArray*>(arr_sliced.get())->values();
+    auto expected_values = ArrayFromJSON(int16(), "[1, 2, 3, 4, 5]");
+    AssertArraysEqual(*expected_values, *values);

Review Comment:
   > Because we use the offsets to slice into the flat values, and those 
offsets take into account potential values behind a null?
   
   Oh now I remember, and I think I understand what you are saying here better 
now. For the fixed size lists, the values behind a null entry in the list are 
removed when we call `Flatten()`. When we go back to try to reconstruct the 
lists based on offsets, the offsets produced by `value_offset` are all invalid 
since they don't account for the values we dropped in `Flatten()`.



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