felipecrv commented on PR #36800: URL: https://github.com/apache/arrow/pull/36800#issuecomment-1648974431
> > If I understand correctly each DURATION operand is being converted to a FLOAT64 before the division, so `x NANO / y MILLI` will first divide `x` by `1e9`, then `y` by `1e3`, and then perform another division with those two results. > > Not really. [`ArithmeticFunction`](https://github.com/apache/arrow/blob/main/cpp/src/arrow/compute/kernels/scalar_arithmetic.cc#L638) will cast them to the finer common unit, not SECOND. So in the case of `x NANO / y MILLI`, `y` would be casted to NANO first, resulting in `x / (y * 1e6)`. I believe this is effectively the same as the algorithm you proposed. > > I also added a DispatchBest test to demonstrate this. Thanks. TIL. Having the dispatching code find the best unit is equivalent to what I was thinking, but very elegant way to go about it. -- 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]
