cloud-fan commented on a change in pull request #21599: [SPARK-26218][SQL] 
Overflow on arithmetic operations returns incorrect result
URL: https://github.com/apache/spark/pull/21599#discussion_r309269787
 
 

 ##########
 File path: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/ArithmeticExpressionSuite.scala
 ##########
 @@ -376,4 +404,100 @@ class ArithmeticExpressionSuite extends SparkFunSuite 
with ExpressionEvalHelper
     Greatest(Seq(Literal(1), Literal(1))).genCode(ctx2)
     assert(ctx2.inlinedMutableStates.size == 1)
   }
+
+  test("SPARK-24598: overflow on long returns wrong result") {
+    val maxLongLiteral = Literal(Long.MaxValue)
+    val minLongLiteral = Literal(Long.MinValue)
+    val e1 = Add(maxLongLiteral, Literal(1L))
+    val e2 = Subtract(maxLongLiteral, Literal(-1L))
+    val e3 = Multiply(maxLongLiteral, Literal(2L))
+    val e4 = Add(minLongLiteral, minLongLiteral)
+    val e5 = Subtract(minLongLiteral, maxLongLiteral)
+    val e6 = Multiply(minLongLiteral, minLongLiteral)
 
 Review comment:
   shall we also test `UnaryMinus`? BTW do you know why the previous mistake in 
`UnaryMinus` code was not caught by the existing tests?

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