kosiew commented on code in PR #24156:
URL: https://github.com/apache/datafusion/pull/24156#discussion_r3800890783


##########
datafusion/spark/src/function/math/abs.rs:
##########
@@ -125,6 +118,18 @@ macro_rules! scalar_compute_op {
     }};
 }
 
+macro_rules! make_try_spark_abs_function {
+    ($ARRAY_TYPE:ident) => {{
+        |input: &ArrayRef| {
+            let array = downcast_named_arg!(&input, "abs arg", $ARRAY_TYPE);
+            let res: $ARRAY_TYPE = array
+                .try_unary(|x| 
x.checked_abs().ok_or_else(arithmetic_overflow_error))
+                .and_then(|v| 
Ok(v.with_data_type(input.data_type().clone())))?;

Review Comment:
   Small suggestion: could we use `.map(|v| v.with_data_type(...))?` here 
instead of `.and_then(|v| Ok(v.with_data_type(...)))?`? Since `with_data_type` 
is infallible, `map` feels a little simpler and makes the intent clearer.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to