edponce commented on a change in pull request #10274:
URL: https://github.com/apache/arrow/pull/10274#discussion_r631529736



##########
File path: cpp/src/arrow/compute/kernels/scalar_arithmetic.cc
##########
@@ -79,22 +79,20 @@ struct AbsoluteValue {
 
   template <typename T, typename Arg>
   static constexpr enable_if_signed_integer<T> Call(KernelContext*, Arg arg, 
Status* st) {
-    return (arg < static_cast<T>(0)) ? arrow::internal::SafeSignedNegate(arg) 
: arg;
+    return std::abs(arg);
   }
 };
 
 struct AbsoluteValueChecked {
   template <typename T, typename Arg>
   static enable_if_signed_integer<T> Call(KernelContext*, Arg arg, Status* st) 
{
     static_assert(std::is_same<T, Arg>::value, "");
-    if (arg < static_cast<T>(0)) {
-      T result = 0;
-      if (ARROW_PREDICT_FALSE(NegateWithOverflow(arg, &result))) {
-        *st = Status::Invalid("overflow");
-      }
-      return result;
+    T result = std::abs(arg);
+    if (result < 0) {
+      *st = Status::Invalid("overflow");
+      return 0;

Review comment:
       Ok, I had noticed that other kernels returned 0 on error (e.g. divide, 
power) and thought it might be a convention. But I agree that the invalid value 
should be returned.




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

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


Reply via email to