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


##########
arrow/src/compute/kernels/arithmetic.rs:
##########
@@ -1236,21 +1283,41 @@ where
     Ok(unary(array, |a| a % modulo))
 }
 
+/// Divide every value in an array by a scalar. If any value in the array is 
null then the
+/// result is also null. If the scalar is zero then it will panic. For a 
variant returning
+/// `Err` on division by zero, use `divide_scalar_checked` instead.
+///
+/// This doesn't detect overflow. Once overflowing, the result will wrap 
around.
+/// For an overflow-checking variant, use `divide_scalar_checked` instead.
+pub fn divide_scalar<T>(
+    array: &PrimitiveArray<T>,
+    divisor: T::Native,
+) -> Result<PrimitiveArray<T>>
+where
+    T: datatypes::ArrowNumericType,
+    T::Native: ArrowNativeTypeOp + Zero,
+{
+    Ok(unary(array, |a| a.div_wrapping(divisor)))
+}
+
 /// Divide every value in an array by a scalar. If any value in the array is 
null then the
 /// result is also null. If the scalar is zero then the result of this 
operation will be
 /// `Err(ArrowError::DivideByZero)`.
-pub fn divide_scalar<T>(
+///
+/// This detects overflow and returns an `Err` for that. For an 
non-overflow-checking variant,
+/// use `divide_scalar` instead.
+pub fn divide_scalar_checked<T>(

Review Comment:
   Sure, I've thought about it and wondered maybe #2647 can be resolved 
quickly. 😄 
   
   Let me remove division first.



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