You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/04/23 11:16:12 UTC

[GitHub] [spark] AngersZhuuuu commented on a change in pull request #32314: [SPARK-35169][SQL] Fix wrong result of min ANSI interval division by -1

AngersZhuuuu commented on a change in pull request #32314:
URL: https://github.com/apache/spark/pull/32314#discussion_r619140377



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/intervalExpressions.scala
##########
@@ -402,6 +403,19 @@ case class DivideYMInterval(
   override def inputTypes: Seq[AbstractDataType] = Seq(YearMonthIntervalType, NumericType)
   override def dataType: DataType = YearMonthIntervalType
 
+  def checkDivideOverflow(month: Int, num: Any): Unit = {
+    if (month == Int.MinValue) {
+      num match {
+        case l: Long if l == -1L => throw QueryExecutionErrors.overflowInIntegralDivideError()
+        case number: Number if number.doubleValue() == -1.0D =>
+          throw QueryExecutionErrors.overflowInIntegralDivideError()
+        case decimal: Decimal if decimal.equals(Decimal.apply(-1)) =>

Review comment:
       -2147483648 / -1 = -2147483648 is reasonable?
   
   Looks so strange...




-- 
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:
users@infra.apache.org



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