kiszk commented on a change in pull request #10350:
URL: https://github.com/apache/arrow/pull/10350#discussion_r638959942



##########
File path: cpp/src/gandiva/gdv_function_stubs_test.cc
##########
@@ -290,4 +299,53 @@ TEST(TestGdvFnStubs, TestCastVARCHARFromDouble) {
   EXPECT_FALSE(ctx.has_error());
 }
 
+TEST(TestGdvFnStubs, TestAbs) {
+  gandiva::ExecutionContext ctx;
+  uint64_t ctx_ptr = reinterpret_cast<int64_t>(&ctx);
+
+  // Abs functions
+  EXPECT_EQ(gdv_fn_abs_int32(ctx_ptr, 0), 0);
+  EXPECT_EQ(gdv_fn_abs_uint32(ctx_ptr, 0), 0);
+  EXPECT_EQ(gdv_fn_abs_int64(ctx_ptr, 0), 0L);
+  EXPECT_EQ(gdv_fn_abs_uint64(ctx_ptr, 0), 0L);
+  VerifyAlmostEquals(gdv_fn_abs_float32(ctx_ptr, 0.0f), abs(0.0f));
+  VerifyAlmostEquals(gdv_fn_abs_float64(ctx_ptr, 0.0), abs(0.0));
+
+  VerifyAlmostEquals(gdv_fn_abs_int32(ctx_ptr, (INT32_MIN + 1)),
+                     abs(static_cast<double>(INT32_MIN + 1)));
+  VerifyAlmostEquals(gdv_fn_abs_int64(ctx_ptr, (INT32_MIN + 1)),
+                     abs(static_cast<double>(INT32_MIN + 1)));
+  VerifyAlmostEquals(gdv_fn_abs_float32(ctx_ptr, static_cast<float>(INT32_MIN 
+ 1)),
+                     abs(static_cast<float>(INT32_MIN + 1)));
+  VerifyAlmostEquals(gdv_fn_abs_float64(ctx_ptr, static_cast<double>(INT32_MIN 
+ 1)),
+                     abs(static_cast<double>(INT32_MIN + 1)));
+
+  EXPECT_EQ(gdv_fn_abs_int64(ctx_ptr, (INT64_MIN + 1)),

Review comment:
       Sorry, I thought the previous version of abs is to cast int64 to double 
long. But, now, `gdv_fn_abs_int64` handles as int64. Correct?




-- 
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:
[email protected]


Reply via email to