mbutrovich opened a new issue, #12002: URL: https://github.com/apache/arrow-rs/issues/12002
**Describe the bug** The rustdoc of [`binary_mut`](https://github.com/apache/arrow-rs/blob/9ffd63d528e924d9c0faceef0027e3766b615c98/arrow-arith/src/arity.rs#L148-L153) says that if the buffer of `a` is shared, it returns `Err(self)`, and `try_binary_mut` refers to it for buffer reuse. For an empty `a`, both return `Ok(Ok(empty array))` even when the buffer is shared, because they [return early](https://github.com/apache/arrow-rs/blob/9ffd63d528e924d9c0faceef0027e3766b615c98/arrow-arith/src/arity.rs#L217-L223) before `into_builder` (the same in [`try_binary_mut`](https://github.com/apache/arrow-rs/blob/9ffd63d528e924d9c0faceef0027e3766b615c98/arrow-arith/src/arity.rs#L327-L331)). `unary_mut` and `try_unary_mut` call [`into_builder`](https://github.com/apache/arrow-rs/blob/9ffd63d528e924d9c0faceef0027e3766b615c98/arrow-array/src/array/primitive_array.rs#L987) first, so they return `Err(self)` for the same input. No buffer is changed, so this is a difference between the documentation and the behavior, and between the unary and binary forms. **To Reproduce** On `main` at 9ffd63d528: ```rust use arrow::array::Int32Array; use arrow::compute::{binary_mut, try_binary_mut, try_unary_mut, unary_mut}; let a = Int32Array::from(Vec::<i32>::new()); let b = Int32Array::from(Vec::<i32>::new()); // Err(self): the buffer is shared with `a` assert!(unary_mut(a.clone(), |x| x + 1).is_err()); assert!(try_unary_mut(a.clone(), |x| Ok(x + 1)).is_err()); // Ok(Ok(empty)) instead of Err(self) assert!(matches!(binary_mut(a.clone(), &b, |x, y| x + y), Ok(Ok(_)))); assert!(matches!(try_binary_mut(a.clone(), &b, |x, y| Ok(x + y)), Ok(Ok(_)))); ``` **Expected behavior** Should the binary forms return `Err(self)` for a shared buffer whatever its length, as the rustdoc says and the unary forms do? Or should all four return `Ok` for an empty array, and the rustdoc say so? **Additional context** Found by a property test of the arity helpers. -- 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]
