tustvold commented on code in PR #4707:
URL: https://github.com/apache/arrow-rs/pull/4707#discussion_r1296339055


##########
arrow-arith/src/arity.rs:
##########
@@ -82,7 +82,7 @@ where
 {
     let dict_values = array.values().as_any().downcast_ref().unwrap();
     let values = unary::<T, F, T>(dict_values, op);
-    Ok(Arc::new(array.with_values(&values)))
+    Ok(Arc::new(array.with_values(Arc::new(values))))

Review Comment:
   This would entail generating code that is generic over both the dictionary 
and all the primitive values, which is precisely what we are trying to avoid 
doing. This categorically should not be the pattern.
   
   Instead users should write a function with a kernel like
   
   ```
   fn my_amazing_kernel(a: &dyn Array) -> Result<ArrayRef> {
       if let Some(a) = as_any_dictionary_array(a) {
           let values = my_amazing_kernel(a.values())?;
           Ok(a.with_values(values))
       }
   
       downcast_primitive_array! {
           a => ...
       }
   }
   ```
   
   



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