ZhangHuiGui opened a new issue, #40123:
URL: https://github.com/apache/arrow/issues/40123

   ### Describe the bug, including details regarding any error messages, 
version, and platform.
   
   Our decimal compute rules are compatible with Redshift’s decimal promotion 
rules.
   In doc: 
[https://arrow.apache.org/docs/cpp/compute.html#arithmetic-functions](https://arrow.apache.org/docs/cpp/compute.html#arithmetic-functions),
 we have the rulse:
   <img width="690" alt="image" 
src="https://github.com/apache/arrow/assets/106943008/624a3854-7323-4fde-b2be-ae0ec4eaeb46";>
   
   But during we add the decimal binary kernels, when we compute out_type, the 
rules are different in add/substract and divide.
   
   Add/substract:
   ```c
           const int32_t scale = s1;
           const int32_t precision = std::max(p1 - s1, p2 - s2) + scale + 1;
           return std::make_pair(precision, scale);
   ```
   Divide:
   ```c
           const int32_t scale = s1 - s2;
           const int32_t precision = p1;
           return std::make_pair(precision, scale);
   ```
   
   Obviously they are wrong, did i miss some background knowledge?
   
   
   ### 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]

Reply via email to