alamb commented on issue #5471: URL: https://github.com/apache/arrow-datafusion/issues/5471#issuecomment-1675875694
> You could but it seems odd to me that you would special case strings, it feels like you should be able to wrap an arbitrary unary function and produce a new function that can handle dictionaries. What I am struggling with is that [`unary`](https://docs.rs/arrow/latest/arrow/compute/fn.unary.html) only works for `ArrowPrimitiveTypes` (aka not `StringArray` / `LargeStringArray`) I do agree that under the covers the handling of Non `DictionaryArray` and `DictionaryArray` could be general Maybe we could also add a function like the following to handle it 🤔 ```rust /// Applies an array --> array transform function /// that will apply the function to dictionary values as well fn apply<F>(input: &dyn Array, f: F) -> Result<ArrayRef> where F: FnMut(&dyn Array) -> Result<ArrayRef> { // if input is dictionary, apply f to values() // otherwise, apply f to input } ``` Maybe it doesn't even need to be dynamic so we could avoid additional code bloat 🤔 -- 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]
