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

   **Is your feature request related to a problem or challenge? Please describe 
what you are trying to do.**
   
   @crepererum  and I are using `BooleanArray` to work as a bitset but the api 
is slightly cumbersome as the compute kernels give back an `ArrayRef` so we 
have to do some clunky downcasting
   
   
   **Describe the solution you'd like**
   I would like some way to convert an `ArrayRef` to `BooleanArray` 
   
   I can go from `ArrayRef` to `&BooleanArray` with functions like 
https://docs.rs/arrow/25.0.0/arrow/array/fn.as_boolean_array.html but I can't 
get the owned version  
   
   
   Here is a specific example / reproducer:
   
   ```rust
   use std::sync::Arc;
   
   use arrow::{array::{BooleanArray, ArrayRef}, compute::concat};
   
   
   
   fn main() {
       let b1: BooleanArray = [Some(true), Some(true), Some(false), 
Some(false), None].into_iter().collect();
       let b2: BooleanArray = [Some(true), Some(false), Some(true), 
Some(false), None].into_iter().collect();
   
       let output: ArrayRef = concat(&[&b1, &b2]).unwrap();
   
       // I want to get output as a BooleanArray (which it is) but I can't 
figure out how to downcast it
   
       // this almost works but gets an error:
   
   //     --> src/main.rs:16:48
   //     |
   // 16  |     let output: BooleanArray = Arc::try_unwrap(output)
   //     |                                --------------- ^^^^^^ doesn't have 
a size known at compile-time
   //     |                                |
   //     |                                required by a bound introduced by 
this call
   //     |
   
   
       let output: BooleanArray = Arc::try_unwrap(output)
           .unwrap() // take ownership
           .as_any()
           .downcast::<BooleanArray>()
           .unwrap(); // verify it was actually BooleanArray
   }
   ```
   
   It doesn't compile
   
   
   **Describe alternatives you've considered**
   None yet
   
   **Additional context**
   You can see the context of what we are doing on 
https://github.com/influxdata/influxdb_iox/pull/5910 / 
https://github.com/influxdata/influxdb_iox/pull/5910#discussion_r1000479355
   


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