I meant to add a callout to this comment <https://github.com/apache/arrow-rs/issues/12426#issuecomment-7115524882>as well about behavior between other implementations not always being prescriptive:
Arrow C++ has two decimal divides that disagree: - The compute kernel divide divides with BasicDecimal128::operator/ <https://github.com/apache/arrow/blob/373d64c02cb23663b63c5853099fca43a46c39fc/cpp/src/arrow/compute/kernels/base_arithmetic_internal.h#L388-L396>, and that operator's division "rounds to zero" <https://github.com/apache/arrow/blob/373d64c02cb23663b63c5853099fca43a46c39fc/cpp/src/arrow/util/basic_decimal.h#L596-L601>, as arrow-rs does. Its result scale is max(4, s1 + p2 - s2 + 1) <https://github.com/apache/arrow/blob/373d64c02cb23663b63c5853099fca43a46c39fc/docs/source/cpp/compute.rst#L560-L561>, not s1 + 4. - Gandiva's Divide rounds half away from zero <https://github.com/apache/arrow/blob/373d64c02cb23663b63c5853099fca43a46c39fc/cpp/src/gandiva/precompiled/decimal_ops.cc#L375-L378> on its 128-bit path. Thanks, Matt On Mon, Nov 30, 2026 at 11:40 AM Matt Butrovich <[email protected]> wrote: > Hi all, > > I've been doing a lot of optimization work on division for Arrow-rs, and > would like this to be a tentpole feature of the 61.0.0 release. Somewhat > related, the Andy Grove filed an issue about decimal division behavior that > I think we should sort out before the next major release, because it would > be a breaking change: > > https://github.com/apache/arrow-rs/issues/12426 > > Basically, it's a rounding vs. truncation issue and because it would be a > change in behavior I think we should try to sort it out by the next major > release (61.0.0, scheduled for January). I've already added a comment to > the tracking issue to get more eyeballs on it, but I also wanted to ping > the mailing list to get more visibility. I am happy to provide a fix since > I've been touching that code, but would like consensus on the behavior. > > Thanks, > > Matt >
