You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "gotocoding-DB (via GitHub)" <gi...@apache.org> on 2024/11/06 10:36:29 UTC

Re: [PR] [WIP] [SPARK-50226] [SQL] Throw ARITHMETIC_OVERFLOW in MakeYMInterval and MakeDTInterval [spark]

gotocoding-DB commented on code in PR #48773:
URL: https://github.com/apache/spark/pull/48773#discussion_r1830776614


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/intervalExpressions.scala:
##########
@@ -478,17 +478,26 @@ case class MakeYMInterval(years: Expression, months: Expression)
   override def dataType: DataType = YearMonthIntervalType()
 
   override def nullSafeEval(year: Any, month: Any): Any = {
-    Math.toIntExact(Math.addExact(month.asInstanceOf[Number].longValue(),
-      Math.multiplyExact(year.asInstanceOf[Number].longValue(), MONTHS_PER_YEAR)))
+    try {
+      Math.toIntExact(Math.addExact(month.asInstanceOf[Number].longValue(),
+        Math.multiplyExact(year.asInstanceOf[Number].longValue(), MONTHS_PER_YEAR)))

Review Comment:
   I'll move it to separate function, so there will be no need to catch exception in `doGenCode` part.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org