nealrichardson commented on pull request #11355:
URL: https://github.com/apache/arrow/pull/11355#issuecomment-938624975
Here's what R does:
```
> 5 %/% 0
[1] Inf
> typeof(5 %/% 0)
[1] "double"
> 5L %/% 0L
[1] NA
> typeof(5L %/% 0L)
[1] "integer"
```
Leaving aside the questions of type stability, I think it's still accurate
that integer division by 0 should/could return a missing value in Arrow. (It
can't return Inf because that's not an integer.) But that's not what currently
happens, even if you directly call the functions without any of our casting and
wrapping:
```
> call_function("divide", Array$create(5L), Array$create(0L))
Error: Invalid: divide by zero
../src/arrow/compute/exec.cc:695 kernel_->exec(kernel_ctx_, batch, &out)
../src/arrow/compute/exec.cc:633 ExecuteBatch(batch, listener)
../src/arrow/compute/function.cc:239
executor->Execute(implicitly_cast_args, &listener)
> call_function("divide", Array$create(5L), Array$create(0))
Array
<double>
[
inf
]
> call_function("divide_checked", Array$create(5L), Array$create(0))
Error: Invalid: divide by zero
../src/arrow/compute/exec.cc:695 kernel_->exec(kernel_ctx_, batch, &out)
../src/arrow/compute/exec.cc:633 ExecuteBatch(batch, listener)
../src/arrow/compute/function.cc:239
executor->Execute(implicitly_cast_args, &listener)
```
Let's leave aside the integer division question for now, I'll make a
followup jira. Either way, switching to `divide` instead of `divide_checked` is
the right move.
--
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]