alamb commented on code in PR #7037:
URL: https://github.com/apache/arrow-rs/pull/7037#discussion_r1932239250


##########
arrow-select/src/concat.rs:
##########
@@ -156,10 +156,19 @@ fn concat_lists<OffsetSize: OffsetSizeTrait>(
         NullBuffer::new(nulls.finish())
     });
 
-    let values: Vec<&dyn Array> = lists
+    let values: Vec<ArrayRef> = lists
         .iter()
-        .map(|x| x.values().as_ref())
+        .map(|x| {
+            // offsets may not refer to all values in the array
+            // for example a sliced list array may have offsets that start at
+            // a non-zero offset and not use all the values
+            let offsets = x.offsets();
+            let start_offset = offsets[0].as_usize();
+            let end_offset = offsets[offsets.len() - 1].as_usize();
+            x.values().slice(start_offset, end_offset - start_offset)

Review Comment:
   The issue is that the `values` of sliced `ListArray`s do not necessairly 
start at zero
   
   For the test in this PR, the offsets are:
   
   ```
   concat_lists offsets: OffsetBuffer(ScalarBuffer([5, 5, 5]))
   concat_lists offsets: OffsetBuffer(ScalarBuffer([0, 0, 3, 4]))
   ```



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