@@ -3018,30 +3018,25 @@ class CometExpressionSuite extends CometTestBase with AdaptiveSparkPlanHelper {
30183018 }
30193019
30203020 test(" ANSI support for round function" ) {
3021- val data = Seq ((Integer .MAX_VALUE , Integer .MIN_VALUE , Long .MinValue , Long .MaxValue ))
3022- Seq (" true" , " false" ).foreach { p =>
3023- withSQLConf(SQLConf .ANSI_ENABLED .key -> p) {
3024- withParquetTable(data, " tbl" ) {
3025- val res = spark.sql(s """
3026- |SELECT
3027- | round(_1, -1) ,
3028- | round(_1, -10) ,
3029- | round( ${Int .MaxValue }, -10)
3030- | from tbl
3031- | """ .stripMargin)
3032-
3033- checkSparkMaybeThrows(res) match {
3034- case (Some (sparkException), Some (cometException)) =>
3035- assert(sparkException.getMessage.contains(" ARITHMETIC_OVERFLOW" ))
3036- assert(cometException.getMessage.contains(" ARITHMETIC_OVERFLOW" ))
3037- case (None , None ) => checkSparkAnswerAndOperator(res)
3038- case (None , Some (ex)) =>
3039- fail(
3040- " Comet threw an exception but Spark did not. Comet exception: " + ex.getMessage)
3041- case (Some (sparkException), None ) =>
3042- fail(
3043- " Spark threw an exception but Comet did not. Spark exception: " +
3044- sparkException.getMessage)
3021+ Seq ((Integer .MAX_VALUE , Integer .MIN_VALUE , Long .MinValue , Long .MaxValue )).foreach { value =>
3022+ val data = Seq (value)
3023+ withParquetTable(data, " tbl" ) {
3024+ Seq (- 1000 , - 100 , - 10 , - 1 , 0 , 1 , 10 , 100 , 1000 ).foreach { scale =>
3025+ Seq (true , false ).foreach { ansi =>
3026+ withSQLConf(SQLConf .ANSI_ENABLED .key -> ansi.toString) {
3027+ val res = spark.sql(s " SELECT round(_1, $scale) from tbl " )
3028+ checkSparkMaybeThrows(res) match {
3029+ case (Some (sparkException), Some (cometException)) =>
3030+ assert(sparkException.getMessage.contains(" ARITHMETIC_OVERFLOW" ))
3031+ assert(cometException.getMessage.contains(" ARITHMETIC_OVERFLOW" ))
3032+ case (None , None ) => checkSparkAnswerAndOperator(res)
3033+ case (None , Some (ex)) =>
3034+ fail(" Comet threw an exception but Spark did not. Comet exception: " + ex.getMessage)
3035+ case (Some (sparkException), None ) =>
3036+ fail(" Spark threw an exception but Comet did not. Spark exception: " +
3037+ sparkException.getMessage)
3038+ }
3039+ }
30453040 }
30463041 }
30473042 }
0 commit comments