You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/07/07 07:39:59 UTC

[GitHub] [arrow-rs] viirya commented on a diff in pull request #1983: Support dictionary array for divide kernel

viirya commented on code in PR #1983:
URL: https://github.com/apache/arrow-rs/pull/1983#discussion_r915559201


##########
arrow/src/compute/kernels/arithmetic.rs:
##########
@@ -892,6 +984,18 @@ where
     return math_checked_divide_op(left, right, |a, b| a / b);
 }
 
+/// Perform `left / right` operation on two arrays. If either left or right value is null
+/// then the result is also null. If any right hand value is zero then the result of this
+/// operation will be `Err(ArrowError::DivideByZero)`.
+pub fn divide_dyn(left: &dyn Array, right: &dyn Array) -> Result<ArrayRef> {
+    match left.data_type() {
+        DataType::Dictionary(_, _) => {
+            typed_dict_math_op!(left, right, |a, b| a / b, math_divide_checked_op_dict)
+        }
+        _ => typed_math_op!(left, right, |a, b| a / b, math_checked_divide_op),

Review Comment:
   I extracted the called op function as a parameter.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org