viirya commented on code in PR #7904:
URL: https://github.com/apache/arrow-datafusion/pull/7904#discussion_r1368214057
##########
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(|| {
Review Comment:
It is not a bug...If you feed invalid data, the operators/expressions won't
perform correctly.
I mean, if you worry about `abs`'s input could be invalid decimal values,
you will worry other operator/expression takes invalid input too. It doesn't
make sense.
If you have a decimal input with invalid values (for example, it is out of
the representation range of the precision/scale), some operators/expressions
will perform wrongly. But it is not a reason to add such check to all
operators/expressions to verify if input is valid or not. It means that you
will have to validate inputs of each operator/expression.
I think `wrapping_abs` is enough here.
--
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]