alamb commented on code in PR #4707:
URL: https://github.com/apache/arrow-rs/pull/4707#discussion_r1324351181
##########
arrow-arith/src/arity.rs:
##########
@@ -105,10 +105,11 @@ where
let dict_values = array.values().as_any().downcast_ref().unwrap();
let values = try_unary::<T, F, T>(dict_values, op)?;
- Ok(Arc::new(array.with_values(&values)))
+ Ok(Arc::new(array.with_values(Arc::new(values))))
}
/// Applies an infallible unary function to an array with primitive values.
+#[deprecated(note = "Use arrow_array::AnyDictionaryArray")]
Review Comment:
> Otherwise, I guess they all have to repeat the steps of:
I agree the pattern of I have a function I want to apply to an array and I
would like it applied either to a non-dictionary or dictionary encoded version
of that type is very common.
It would be great to avoid clients having to write stuff like
```rust
if let Some(d) = a.as_any_dictionary_opt() {
// Recursively handle dictionary input
let r = my_kernel(d.values().as_ref())?;
return Ok(d.with_values(r));
} else {
// apply my kernel to dictionary input)
return my_kernel(a.as_ref())
}
```
Which forces users to:
1. Remember to handle dictionaries
2. won't automatically work for things like REE (or StringViews)
--
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]