ump45nose opened a new pull request, #55338:
URL: https://github.com/apache/arrow/pull/55338

   ### Rationale for this change
   
   Fixes #55334.
   
   R's `%%` was implemented by rewriting through `%/%`, which casts both sides 
to `float64`. That breaks int64 values outside the exact double range (errors) 
and decimals with many significant digits (silently wrong answers). Arrow C++ 
26.0.0 added a floored `modulo` kernel with the same sign-of-divisor semantics 
as R's `%%`, so the binding can call it directly.
   
   ### What changes are included in this PR?
   
   - `eval_array_expression()` and `Expression$op()` call `modulo` for `%%`.
   - Integer `%% 0` still returns `NA` like base R: zero divisors are 
substituted before the kernel (which errors on divide-by-zero), then those 
positions are set to `NA`.
   - `.operator_map` maps `%%` to `modulo`.
   - Tests for large int64, decimal, integer `%% 0`, and the dplyr binding.
   
   ### Are these changes tested?
   
   Yes — new cases in `r/tests/testthat/test-dplyr-funcs-math.R`.
   
   ### Are there any user-facing changes?
   
   Bug fix for `%%` on large int64 and high-precision decimals. Integer `%% 0` 
behaviour is unchanged (`NA`).
   
   ### AI assistance
   
   AI tooling helped draft the patch and tests; I reviewed it against #55334 
and the existing `%/%` zero-divisor handling.
   


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