andygrove commented on code in PR #2136:
URL: https://github.com/apache/datafusion-comet/pull/2136#discussion_r2353560502
##########
spark/src/test/scala/org/apache/comet/CometExpressionSuite.scala:
##########
@@ -394,15 +397,98 @@ class CometExpressionSuite extends CometTestBase with
AdaptiveSparkPlanHelper {
}
}
- test("test coalesce lazy eval") {
- withSQLConf(
- SQLConf.ANSI_ENABLED.key -> "true",
- CometConf.COMET_EXPR_ALLOW_INCOMPATIBLE.key -> "true") {
- val data = Seq((9999999999999L, 0))
- withParquetTable(data, "t1") {
+ 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") {
+ spark.table("tbl").printSchema()
val res = spark.sql("""
- |SELECT coalesce(_1, CAST(_1 AS TINYINT)) from t1;
- | """.stripMargin)
+ |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") {
Review Comment:
Could you add separate tests for `divide` and `integral_divide`, and also
for `remainder`.
--
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]