tustvold commented on code in PR #2717:
URL: https://github.com/apache/arrow-rs/pull/2717#discussion_r973215572
##########
arrow/src/compute/kernels/arithmetic.rs:
##########
@@ -1225,12 +1143,17 @@ where
pub fn divide_dyn(left: &dyn Array, right: &dyn Array) -> Result<ArrayRef> {
match left.data_type() {
DataType::Dictionary(_, _) => {
- typed_dict_math_op!(left, right, |a, b| a / b,
math_divide_checked_op_dict)
+ typed_dict_math_op!(
+ left,
+ right,
+ |a, b| a.div_checked(b),
Review Comment:
I think we're fine the definition of `div_checked` for integral types is
```
if rhs.is_zero() {
Err(ArrowError::DivideByZero)
} else {
self.checked_div(rhs).ok_or_else(|| {
ArrowError::ComputeError(format!(
"Overflow happened on: {:?} / {:?}",
self, rhs
))
})
}
```
The checked_div is technically redundant as we've already checked that the
value isn't zero, i.e. this code could be simplified to
```
self.checked_div(rhs).ok_or_else(|| {
ArrowError::DivideByZero
})
```
The definition for floating points is
```
if rhs.is_zero() {
Err(ArrowError::DivideByZero)
} else {
Ok(self / rhs)
}
```
Which will not check for overflow, as it isn't meaningful to do so for
floats?
TLDR: I don't think overflow checking for division makes sense?
--
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]