vegarsti commented on code in PR #18424:
URL: https://github.com/apache/datafusion/pull/18424#discussion_r2483157948


##########
datafusion/functions-nested/src/reverse.rs:
##########
@@ -183,6 +195,35 @@ fn general_array_reverse<O: OffsetSizeTrait + 
TryFrom<i64>>(
     )?))
 }
 
+fn list_view_reverse<O: OffsetSizeTrait + TryFrom<i64>>(
+    array: &GenericListViewArray<O>,
+    _field: &FieldRef,
+) -> Result<ArrayRef> {
+    let (field, offsets, sizes, values, nulls) = array.clone().into_parts();
+
+    // Construct indices corresponding to the reversed arrays
+    let mut indices: Vec<u32> = Vec::with_capacity(values.len());
+    for (i, offset) in offsets.iter().enumerate().take(offsets.len()) {
+        // Each array is located at [offset, offset + size), so we collect 
indices in the reverse order
+        let array_start = offset.as_usize();
+        let array_end = array_start + sizes[i].as_usize();
+        for idx in (array_start..array_end).rev() {
+            indices.push(idx.try_into().unwrap());

Review Comment:
   We need to avoid this `unwrap`! But I haven't figured out how to return a 
Result<_, DataFusionError> correctly



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to