mgaido91 commented on a change in pull request #25461: [SPARK-28741][SQL]Throw
exceptions when casting to integers causes overflow
URL: https://github.com/apache/spark/pull/25461#discussion_r317001160
##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/types/Decimal.scala
##########
@@ -232,12 +232,149 @@ final class Decimal extends Ordered[Decimal] with
Serializable {
}
}
+ /**
+ * @return the Long value that is equal to the rounded decimal.
+ * @throws ArithmeticException if checkOverflow is true and
+ * the decimal too big to fit in Long type.
+ */
+ def toLong(checkOverflow: Boolean): Long = {
Review comment:
for 2, anyway, the usage is already different and here we're not in a
`Numeric`-like class. On 1, I am not sure it is a problem. `Decimal` is
`Unstable` and this patch will go in Spark 3.0, so it is a major release (best
place where to put a breaking change!). And the benefit to avoid extra function
calls and a lot of duplicated code is worth the change IMHO.
cc @cloud-fan @maropu for their opinion on this too, but I feel quite strong
about this.
----------------------------------------------------------------
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]