andygrove commented on code in PR #2136:
URL: https://github.com/apache/datafusion-comet/pull/2136#discussion_r2379318448
##########
spark/src/test/scala/org/apache/comet/CometExpressionSuite.scala:
##########
@@ -2854,6 +2857,88 @@ class CometExpressionSuite extends CometTestBase with
AdaptiveSparkPlanHelper {
}
}
+ test("ANSI support for add") {
+ val data = Seq((Integer.MAX_VALUE, 1), (Integer.MIN_VALUE, -1))
+ withSQLConf(SQLConf.ANSI_ENABLED.key -> "true") {
+ withParquetTable(data, "tbl") {
+ val res = spark.sql("""
+ |SELECT
+ | _1 + _2
+ | from tbl
+ | """.stripMargin)
+
+ checkSparkMaybeThrows(res) match {
+ case (Some(sparkExc), Some(cometExc)) =>
+
assert(cometExc.getMessage.contains(ARITHMETIC_OVERFLOW_EXCEPTION_MSG))
+ assert(sparkExc.getMessage.contains("overflow"))
+ case _ => fail("Exception should be thrown")
+ }
+ }
+ }
+ }
+
+ test("ANSI support for subtract") {
+ val data = Seq((Integer.MIN_VALUE, 1))
+ withSQLConf(SQLConf.ANSI_ENABLED.key -> "true") {
+ withParquetTable(data, "tbl") {
+ val res = spark.sql("""
+ |SELECT
+ | _1 - _2
+ | from tbl
+ | """.stripMargin)
+ checkSparkMaybeThrows(res) match {
+ case (Some(sparkExc), Some(cometExc)) =>
+
assert(cometExc.getMessage.contains(ARITHMETIC_OVERFLOW_EXCEPTION_MSG))
+ assert(sparkExc.getMessage.contains("overflow"))
+ case _ => fail("Exception should be thrown")
+ }
+ }
+ }
+ }
+
+ test("ANSI support for multiply") {
+ val data = Seq((Integer.MAX_VALUE, 10))
+ withSQLConf(SQLConf.ANSI_ENABLED.key -> "true") {
+ withParquetTable(data, "tbl") {
+ val res = spark.sql("""
+ |SELECT
+ | _1 * _2
+ | from tbl
+ | """.stripMargin)
+
+ checkSparkMaybeThrows(res) match {
+ case (Some(sparkExc), Some(cometExc)) =>
+
assert(cometExc.getMessage.contains(ARITHMETIC_OVERFLOW_EXCEPTION_MSG))
+ assert(sparkExc.getMessage.contains("overflow"))
+ case _ => fail("Exception should be thrown")
+ }
+ }
+ }
+ }
+
+ test("ANSI support for divide (division by zero)") {
+ // TODO : Support ANSI mode in Integral divide
Review Comment:
Does this TODO still need to be addressed? Perhaps we need a link to another
issue?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]