ZhangHuiGui opened a new issue, #40911: URL: https://github.com/apache/arrow/issues/40911
### Describe the bug, including details regarding any error messages, version, and platform. This is a recently discovered bug that was previously ignored. When we perform Bind on the division of two decimal types decimal(p1,s1), decimal(p2,s2), except for the case of s1<s2, the other output decimal types's precision and scale are both wrong.(Different with our expect rules : https://arrow.apache.org/docs/cpp/compute.html#arithmetic-functions) Because the rule constraints in the output type resolver are not strict. Many situations, such as (s1=s2 || s2 > s2), will directly return success and skip the DispatchBest in BindNonRecursive, thus getting a wrong precision and scale. https://github.com/apache/arrow/blob/9f0101ec14336b2baad45d57320fb56c71d9321b/cpp/src/arrow/compute/kernels/scalar_arithmetic.cc#L543-L547 This means that we should make all decimal divisions go into DispatchBest, but we haven't thought of an elegant solution yet. For example: The first time you enter ResolveDecimalDivisionOutput, it returns invalid, let the upper Bind go to dispatchBest, and the second time you enter it, it will execute the current logic. ### Component(s) C++ -- 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]
