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

   **Is your feature request related to a problem or challenge? Please describe 
what you are trying to do.**
   While implementing https://github.com/apache/datafusion/pull/12792  and 
various other things in DataFusion I find myself often wanting to combine a 
filter and a null mask 
   
   The relevant code is like
   
   ```rust
           // combine existing nulls, if any, and a filter:
           let nulls = filtered_null_mask(opt_filter, input);
   
           // make a new array with a new null buffer
           let output: ArrayRef = match input.data_type() {
               // TODO it would be nice to have safe apis in arrow-rs to update 
the null buffers in the arrays
               DataType::Utf8 => {
                   let input = input.as_string::<i32>();
                   // safety: values / offsets came from a valid string array, 
so are valid utf8
                   // and we checked nulls has the same length as values
                   unsafe {
                       Arc::new(StringArray::new_unchecked(
                           input.offsets().clone(),
                           input.values().clone(),
                           nulls,
                       ))
                   }
               }
   ```
   
   **Describe the solution you'd like**
   I would like an API like `with_nulls` that returns a new array with the same 
data but a new null mask so my code would look like
   
   ```rust
           // combine existing nulls, if any, and a filter:
           let nulls = filtered_null_mask(opt_filter, input);
   
           // make a new array, with the same data but a new null buffer
           // panics if the nulls length doesn't match the array's length
           let output = input.with_nulls(nulls);
   ```
   
   **Describe alternatives you've considered**
   I can keep using the unsafe APIs
   
   **Additional context**
   


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