HaoYang670 commented on code in PR #2740:
URL: https://github.com/apache/arrow-rs/pull/2740#discussion_r973527980


##########
arrow/src/compute/kernels/arithmetic.rs:
##########
@@ -78,6 +80,30 @@ where
     Ok(binary(left, right, op))
 }
 
+/// This is similar to `math_op` as it performs given operation between two 
input primitive arrays.
+/// But the given operation can return `Err` if overflow is detected. For the 
case, this function
+/// returns an `Err`.
+fn math_checked_op<LT, RT, F>(
+    left: &PrimitiveArray<LT>,
+    right: &PrimitiveArray<RT>,
+    op: F,
+) -> Result<PrimitiveArray<LT>>
+where
+    LT: ArrowNumericType,
+    RT: ArrowNumericType,
+    F: Fn(LT::Native, RT::Native) -> Result<LT::Native>,
+    LT::Native: ArrowNativeTypeOp,
+    RT::Native: ArrowNativeTypeOp,
+{
+    if left.len() != right.len() {

Review Comment:
   Ha, I actually I met this error and still debug it. It is really an 
interesting problem of the type system.
   
   Then the PR is good. 👍 And we can investigate the problem in a follow-up 
issue. 



##########
arrow/src/compute/kernels/arithmetic.rs:
##########
@@ -78,6 +80,30 @@ where
     Ok(binary(left, right, op))
 }
 
+/// This is similar to `math_op` as it performs given operation between two 
input primitive arrays.
+/// But the given operation can return `Err` if overflow is detected. For the 
case, this function
+/// returns an `Err`.
+fn math_checked_op<LT, RT, F>(
+    left: &PrimitiveArray<LT>,
+    right: &PrimitiveArray<RT>,
+    op: F,
+) -> Result<PrimitiveArray<LT>>
+where
+    LT: ArrowNumericType,
+    RT: ArrowNumericType,
+    F: Fn(LT::Native, RT::Native) -> Result<LT::Native>,
+    LT::Native: ArrowNativeTypeOp,
+    RT::Native: ArrowNativeTypeOp,
+{
+    if left.len() != right.len() {

Review Comment:
   Ha, actually I met this error and still debug it. It is really an 
interesting problem of the type system.
   
   Then the PR is good. 👍 And we can investigate the problem in a follow-up 
issue. 



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