jonahgao commented on code in PR #7904:
URL: https://github.com/apache/arrow-datafusion/pull/7904#discussion_r1368048094


##########
datafusion/physical-expr/src/math_expressions.rs:
##########
@@ -701,6 +701,29 @@ macro_rules! make_try_abs_function {
     }};
 }
 
+// Decimal types should keep the same precision and scale by using 
`with_data_type()`.
+// https://github.com/apache/arrow-rs/issues/4644
+macro_rules! make_decimal_abs_function {
+    ($ARRAY_TYPE:ident) => {{
+        |args: &[ArrayRef]| {
+            let array = downcast_arg!(&args[0], "abs arg", $ARRAY_TYPE);
+            let res: $ARRAY_TYPE = array
+                .try_unary(|x| {
+                    // Valid Decimal values should never overflow
+                    x.checked_abs().ok_or_else(|| {
+                        ArrowError::InvalidArgumentError(format!(
+                            "Invalid {} value {} when calculating abs",
+                            stringify!($ARRAY_TYPE),
+                            x

Review Comment:
   @viirya I would like to emphasize that the input is illegal for the same 
reason mentioned above.



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