mgaido91 commented on a change in pull request #25144: [SPARK-28369][SQL] Honor 
spark.sql.decimalOperations.nullOnOverflow in ScalaUDF result
URL: https://github.com/apache/spark/pull/25144#discussion_r303256343
 
 

 ##########
 File path: sql/catalyst/src/main/scala/org/apache/spark/sql/types/Decimal.scala
 ##########
 @@ -414,20 +414,12 @@ final class Decimal extends Ordered[Decimal] with 
Serializable {
 
   def floor: Decimal = if (scale == 0) this else {
     val newPrecision = DecimalType.bounded(precision - scale + 1, 0).precision
-    val res = toPrecision(newPrecision, 0, ROUND_FLOOR)
-    if (res == null) {
-      throw new AnalysisException(s"Overflow when setting precision to 
$newPrecision")
-    }
-    res
 
 Review comment:
   Well, I did this for 2 reasons:
    1. Coherency in the exception we throw when an overflow occurs;
    2. Since we are already doing all the needed checks in `toPrecision`, 
checking everything again here is an overhead which can be avoided.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

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

Reply via email to