alamb commented on issue #5471: URL: https://github.com/apache/arrow-datafusion/issues/5471#issuecomment-1675855798
> I presume this is what you intend to do, but I would recommend implementing this by evaluating the function on the dictionary values using the existing kernels, and then passing the result from this into the take kernel with the dictionary keys as the second argument. @tustvold Since this is such a common operation (write a function that applies a function to a `StringArray` / `LargeStringArray` / `DictionaryArray`) I was wondering if we could make a function like https://docs.rs/arrow/latest/arrow/compute/fn.unary.html to do the dispatch and apply Maybe something like ```rust // apply f to each element of array, which writes the result to a temporary string // resulting in the same type of array out fn unary_str<F>(apply: &dyn Array, f: F) -> Result<ArrayRef> where: F: FnMut(&str) -> Cow<str> { ... } ``` Then writing `upper` would look like ```rust unary_str(&input_array, |in| { // this cold be substantially fancier and avoid allocations, etc if the output // was already upper case, etc Cow::from(in.to_uppercase()) } ``` -- 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]
