cloud-fan commented on code in PR #36698:
URL: https://github.com/apache/spark/pull/36698#discussion_r885219727


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala:
##########
@@ -323,11 +390,27 @@ case class Add(
 
   override def decimalMethod: String = "$plus"
 
+  // *   Operation    Result Precision                        Result Scale
+  // *   
------------------------------------------------------------------------
+  // *   e1 + e2      max(s1, s2) + max(p1-s1, p2-s2) + 1     max(s1, s2)

Review Comment:
   ```
   // The formula follows Hive which is based on the SQL standard and MS SQL:
   // 
https://cwiki.apache.org/confluence/download/attachments/27362075/Hive_Decimal_Precision_Scale_Support.pdf
   // https://msdn.microsoft.com/en-us/library/ms190476.aspx
   // Result Precision: max(s1, s2) + max(p1-s1, p2-s2) + 1
   // Result Scale:     max(s1, s2)
   ```



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to