jonmmease opened a new issue, #3471:
URL: https://github.com/apache/arrow-rs/issues/3471

   **Describe the bug**
   In looking into https://github.com/apache/arrow-datafusion/issues/4828, I 
came across what I think is an issue with the `take` kernel when operating on 
List arrays.  It seems that when a taken element of the list array is an empty 
list, the value becomes `null` in the result of take.
   
   I think this is a bug, but let me know if it's the intended behavior.
   
   **To Reproduce**
   Here is an example that stats with the list array: `[[0], [], [1]]` and 
takes elements `[0, 1, 2]`.
   
   ```rust
   use arrow::array::{Int32Array, Int32Builder, ListBuilder};
   use arrow::compute::take;
   
   #[test]
   fn test_take() {
       let mut val_builder = Int32Builder::new();
       let mut list_builder = ListBuilder::new(val_builder);
       list_builder.values().append_value(0);
       list_builder.append(true);
       list_builder.append(true);
       list_builder.values().append_value(1);
       list_builder.append(true);
       let list = list_builder.finish();
   
       println!("list: {:?}", list);
       let indices = Int32Array::from(vec![0, 1, 2]);
       let taken = take(&list, &indices, None).unwrap();
   
       println!("taken: {:?}", taken);
   }
   ```
   output
   ```
   list: ListArray
   [
     PrimitiveArray<Int32>
   [
     0,
   ],
     PrimitiveArray<Int32>
   [
   ],
     PrimitiveArray<Int32>
   [
     1,
   ],
   ]
   
   taken: ListArray
   [
     PrimitiveArray<Int32>
   [
     0,
   ],
     null,
     PrimitiveArray<Int32>
   [
     1,
   ],
   ]
   ```
   
   **Expected behavior**
   I would expect the result to be the same as the input (`[[0], [], [1]]`), 
but instead the result is `[[0], null, [1]`.
   
   **Additional context**
   It looks like this behavior is the result of 
   
   
https://github.com/apache/arrow-rs/blob/2d2d0a3ba72efb5ee82324064f7c7678c2dd8336/arrow-select/src/take.rs#L706-L710
   


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