This is an automated email from the ASF dual-hosted git repository. gengliang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push: new 939c2402c81 Revert "[SPARK-39917][SQL] Use different error classes for numeric/interval arithmetic overflow" 939c2402c81 is described below commit 939c2402c81ad98c5ab65b285ddbcc8825ecffeb Author: Gengliang Wang <gengli...@apache.org> AuthorDate: Mon Aug 1 14:04:17 2022 -0700 Revert "[SPARK-39917][SQL] Use different error classes for numeric/interval arithmetic overflow" This reverts commit 1b6f14ff8c324454b0a44b2439aa42441af2dd81. --- core/src/main/resources/error/error-classes.json | 8 +--- .../sql/catalyst/expressions/arithmetic.scala | 20 +++++----- .../catalyst/expressions/intervalExpressions.scala | 3 +- .../sql/catalyst/util/IntervalMathUtils.scala | 46 ---------------------- .../spark/sql/errors/QueryExecutionErrors.scala | 14 ------- .../sql-tests/results/ansi/interval.sql.out | 14 +++---- .../resources/sql-tests/results/interval.sql.out | 14 +++---- .../sql-tests/results/postgreSQL/int4.sql.out | 12 +++--- .../sql-tests/results/postgreSQL/int8.sql.out | 8 ++-- .../results/postgreSQL/window_part2.sql.out | 4 +- .../apache/spark/sql/DataFrameAggregateSuite.scala | 8 ++-- 11 files changed, 41 insertions(+), 110 deletions(-) diff --git a/core/src/main/resources/error/error-classes.json b/core/src/main/resources/error/error-classes.json index ed6dd112e9f..c4b59799f88 100644 --- a/core/src/main/resources/error/error-classes.json +++ b/core/src/main/resources/error/error-classes.json @@ -7,7 +7,7 @@ }, "ARITHMETIC_OVERFLOW" : { "message" : [ - "<message>.<alternative> If necessary set <config> to \"false\" to bypass this error." + "<message>.<alternative> If necessary set <config> to \"false\" (except for ANSI interval type) to bypass this error." ], "sqlState" : "22003" }, @@ -210,12 +210,6 @@ "<message>" ] }, - "INTERVAL_ARITHMETIC_OVERFLOW" : { - "message" : [ - "<message>.<alternative>" - ], - "sqlState" : "22003" - }, "INTERVAL_DIVIDED_BY_ZERO" : { "message" : [ "Division by zero. Use `try_divide` to tolerate divisor being 0 and return NULL instead." diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala index 24ac685eace..86e6e6d7323 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala @@ -25,7 +25,7 @@ import org.apache.spark.sql.catalyst.expressions.codegen._ import org.apache.spark.sql.catalyst.expressions.codegen.Block._ import org.apache.spark.sql.catalyst.trees.SQLQueryContext import org.apache.spark.sql.catalyst.trees.TreePattern.{BINARY_ARITHMETIC, TreePattern, UNARY_POSITIVE} -import org.apache.spark.sql.catalyst.util.{IntervalMathUtils, IntervalUtils, MathUtils, TypeUtils} +import org.apache.spark.sql.catalyst.util.{IntervalUtils, MathUtils, TypeUtils} import org.apache.spark.sql.errors.QueryExecutionErrors import org.apache.spark.sql.internal.SQLConf import org.apache.spark.sql.types._ @@ -89,7 +89,7 @@ case class UnaryMinus( defineCodeGen(ctx, ev, c => s"$iu.$method($c)") case _: AnsiIntervalType => nullSafeCodeGen(ctx, ev, eval => { - val mathUtils = IntervalMathUtils.getClass.getCanonicalName.stripSuffix("$") + val mathUtils = MathUtils.getClass.getCanonicalName.stripSuffix("$") s"${ev.value} = $mathUtils.negateExact($eval);" }) } @@ -98,8 +98,8 @@ case class UnaryMinus( case CalendarIntervalType if failOnError => IntervalUtils.negateExact(input.asInstanceOf[CalendarInterval]) case CalendarIntervalType => IntervalUtils.negate(input.asInstanceOf[CalendarInterval]) - case _: DayTimeIntervalType => IntervalMathUtils.negateExact(input.asInstanceOf[Long]) - case _: YearMonthIntervalType => IntervalMathUtils.negateExact(input.asInstanceOf[Int]) + case _: DayTimeIntervalType => MathUtils.negateExact(input.asInstanceOf[Long]) + case _: YearMonthIntervalType => MathUtils.negateExact(input.asInstanceOf[Int]) case _ => numeric.negate(input) } @@ -278,8 +278,6 @@ abstract class BinaryArithmetic extends BinaryOperator throw QueryExecutionErrors.notOverrideExpectedMethodsError("BinaryArithmetics", "calendarIntervalMethod", "genCode") - protected def isAnsiInterval: Boolean = dataType.isInstanceOf[AnsiIntervalType] - // Name of the function for the exact version of this expression in [[Math]]. // If the option "spark.sql.ansi.enabled" is enabled and there is corresponding // function in [[Math]], the exact function will be called instead of evaluation with [[symbol]]. @@ -307,7 +305,7 @@ abstract class BinaryArithmetic extends BinaryOperator assert(exactMathMethod.isDefined, s"The expression '$nodeName' must override the exactMathMethod() method " + "if it is supposed to operate over interval types.") - val mathUtils = IntervalMathUtils.getClass.getCanonicalName.stripSuffix("$") + val mathUtils = MathUtils.getClass.getCanonicalName.stripSuffix("$") defineCodeGen(ctx, ev, (eval1, eval2) => s"$mathUtils.${exactMathMethod.get}($eval1, $eval2)") // byte and short are casted into int when add, minus, times or divide case ByteType | ShortType => @@ -408,9 +406,9 @@ case class Add( IntervalUtils.add( input1.asInstanceOf[CalendarInterval], input2.asInstanceOf[CalendarInterval]) case _: DayTimeIntervalType => - IntervalMathUtils.addExact(input1.asInstanceOf[Long], input2.asInstanceOf[Long]) + MathUtils.addExact(input1.asInstanceOf[Long], input2.asInstanceOf[Long]) case _: YearMonthIntervalType => - IntervalMathUtils.addExact(input1.asInstanceOf[Int], input2.asInstanceOf[Int]) + MathUtils.addExact(input1.asInstanceOf[Int], input2.asInstanceOf[Int]) case _: IntegerType if failOnError => MathUtils.addExact(input1.asInstanceOf[Int], input2.asInstanceOf[Int], getContextOrNull()) case _: LongType if failOnError => @@ -477,9 +475,9 @@ case class Subtract( IntervalUtils.subtract( input1.asInstanceOf[CalendarInterval], input2.asInstanceOf[CalendarInterval]) case _: DayTimeIntervalType => - IntervalMathUtils.subtractExact(input1.asInstanceOf[Long], input2.asInstanceOf[Long]) + MathUtils.subtractExact(input1.asInstanceOf[Long], input2.asInstanceOf[Long]) case _: YearMonthIntervalType => - IntervalMathUtils.subtractExact(input1.asInstanceOf[Int], input2.asInstanceOf[Int]) + MathUtils.subtractExact(input1.asInstanceOf[Int], input2.asInstanceOf[Int]) case _: IntegerType if failOnError => MathUtils.subtractExact( input1.asInstanceOf[Int], diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/intervalExpressions.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/intervalExpressions.scala index 5378639e683..f7ec82de11b 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/intervalExpressions.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/intervalExpressions.scala @@ -607,8 +607,7 @@ trait IntervalDivide { context: SQLQueryContext): Unit = { if (value == minValue && num.dataType.isInstanceOf[IntegralType]) { if (numValue.asInstanceOf[Number].longValue() == -1) { - throw QueryExecutionErrors.intervalArithmeticOverflowError( - "Interval value overflows after being divided by -1", "try_divide", context) + throw QueryExecutionErrors.overflowInIntegralDivideError(context) } } } diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/IntervalMathUtils.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/IntervalMathUtils.scala deleted file mode 100644 index 28cdb82c8e6..00000000000 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/IntervalMathUtils.scala +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.spark.sql.catalyst.util - -import org.apache.spark.sql.errors.QueryExecutionErrors - -/** - * Helper functions for interval arithmetic operations with overflow. - */ -object IntervalMathUtils { - - def addExact(a: Int, b: Int): Int = withOverflow(Math.addExact(a, b), "try_add") - - def addExact(a: Long, b: Long): Long = withOverflow(Math.addExact(a, b), "try_add") - - def subtractExact(a: Int, b: Int): Int = withOverflow(Math.subtractExact(a, b), "try_subtract") - - def subtractExact(a: Long, b: Long): Long = withOverflow(Math.subtractExact(a, b), "try_subtract") - - def negateExact(a: Int): Int = withOverflow(Math.negateExact(a)) - - def negateExact(a: Long): Long = withOverflow(Math.negateExact(a)) - - private def withOverflow[A](f: => A, hint: String = ""): A = { - try { - f - } catch { - case e: ArithmeticException => - throw QueryExecutionErrors.intervalArithmeticOverflowError(e.getMessage, hint) - } - } -} diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala index b2eca063146..3644e7c0df8 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala @@ -535,20 +535,6 @@ private[sql] object QueryExecutionErrors extends QueryErrorsBase { s"${toSQLValue(eval1, ShortType)} $symbol ${toSQLValue(eval2, ShortType)} caused overflow") } - def intervalArithmeticOverflowError( - message: String, - hint: String = "", - context: Option[SQLQueryContext] = None): ArithmeticException = { - val alternative = if (hint.nonEmpty) { - s" Use '$hint' to tolerate overflow and return NULL instead." - } else "" - new SparkArithmeticException( - errorClass = "INTERVAL_ARITHMETIC_OVERFLOW", - messageParameters = Array(message, alternative), - context = context, - summary = getSummary(context)) - } - def failedToCompileMsg(e: Exception): String = { s"failed to compile: $e" } diff --git a/sql/core/src/test/resources/sql-tests/results/ansi/interval.sql.out b/sql/core/src/test/resources/sql-tests/results/ansi/interval.sql.out index 19e8fbc8c9f..e96ab297d2a 100644 --- a/sql/core/src/test/resources/sql-tests/results/ansi/interval.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/ansi/interval.sql.out @@ -1786,7 +1786,7 @@ select -(a) from values (interval '-2147483648 months', interval '2147483647 mon struct<> -- !query output org.apache.spark.SparkArithmeticException -[INTERVAL_ARITHMETIC_OVERFLOW] integer overflow. +[ARITHMETIC_OVERFLOW] integer overflow. If necessary set spark.sql.ansi.enabled to "false" (except for ANSI interval type) to bypass this error. -- !query @@ -1795,7 +1795,7 @@ select a - b from values (interval '-2147483648 months', interval '2147483647 mo struct<> -- !query output org.apache.spark.SparkArithmeticException -[INTERVAL_ARITHMETIC_OVERFLOW] integer overflow. Use 'try_subtract' to tolerate overflow and return NULL instead. +[ARITHMETIC_OVERFLOW] integer overflow. If necessary set spark.sql.ansi.enabled to "false" (except for ANSI interval type) to bypass this error. -- !query @@ -1804,7 +1804,7 @@ select b + interval '1 month' from values (interval '-2147483648 months', interv struct<> -- !query output org.apache.spark.SparkArithmeticException -[INTERVAL_ARITHMETIC_OVERFLOW] integer overflow. Use 'try_add' to tolerate overflow and return NULL instead. +[ARITHMETIC_OVERFLOW] integer overflow. If necessary set spark.sql.ansi.enabled to "false" (except for ANSI interval type) to bypass this error. -- !query @@ -2033,7 +2033,7 @@ SELECT (INTERVAL '-178956970-8' YEAR TO MONTH) / -1 struct<> -- !query output org.apache.spark.SparkArithmeticException -[INTERVAL_ARITHMETIC_OVERFLOW] Interval value overflows after being divided by -1. Use 'try_divide' to tolerate overflow and return NULL instead. +[ARITHMETIC_OVERFLOW] Overflow in integral divide. Use 'try_divide' to tolerate overflow and return NULL instead. If necessary set spark.sql.ansi.enabled to "false" (except for ANSI interval type) to bypass this error. == SQL(line 1, position 8) == SELECT (INTERVAL '-178956970-8' YEAR TO MONTH) / -1 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -2045,7 +2045,7 @@ SELECT (INTERVAL '-178956970-8' YEAR TO MONTH) / -1L struct<> -- !query output org.apache.spark.SparkArithmeticException -[INTERVAL_ARITHMETIC_OVERFLOW] Interval value overflows after being divided by -1. Use 'try_divide' to tolerate overflow and return NULL instead. +[ARITHMETIC_OVERFLOW] Overflow in integral divide. Use 'try_divide' to tolerate overflow and return NULL instead. If necessary set spark.sql.ansi.enabled to "false" (except for ANSI interval type) to bypass this error. == SQL(line 1, position 8) == SELECT (INTERVAL '-178956970-8' YEAR TO MONTH) / -1L ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -2091,7 +2091,7 @@ SELECT (INTERVAL '-106751991 04:00:54.775808' DAY TO SECOND) / -1 struct<> -- !query output org.apache.spark.SparkArithmeticException -[INTERVAL_ARITHMETIC_OVERFLOW] Interval value overflows after being divided by -1. Use 'try_divide' to tolerate overflow and return NULL instead. +[ARITHMETIC_OVERFLOW] Overflow in integral divide. Use 'try_divide' to tolerate overflow and return NULL instead. If necessary set spark.sql.ansi.enabled to "false" (except for ANSI interval type) to bypass this error. == SQL(line 1, position 8) == SELECT (INTERVAL '-106751991 04:00:54.775808' DAY TO SECOND) / -1 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -2103,7 +2103,7 @@ SELECT (INTERVAL '-106751991 04:00:54.775808' DAY TO SECOND) / -1L struct<> -- !query output org.apache.spark.SparkArithmeticException -[INTERVAL_ARITHMETIC_OVERFLOW] Interval value overflows after being divided by -1. Use 'try_divide' to tolerate overflow and return NULL instead. +[ARITHMETIC_OVERFLOW] Overflow in integral divide. Use 'try_divide' to tolerate overflow and return NULL instead. If necessary set spark.sql.ansi.enabled to "false" (except for ANSI interval type) to bypass this error. == SQL(line 1, position 8) == SELECT (INTERVAL '-106751991 04:00:54.775808' DAY TO SECOND) / -1L ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/sql/core/src/test/resources/sql-tests/results/interval.sql.out b/sql/core/src/test/resources/sql-tests/results/interval.sql.out index 8234031021a..53172283d12 100644 --- a/sql/core/src/test/resources/sql-tests/results/interval.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/interval.sql.out @@ -1742,7 +1742,7 @@ select -(a) from values (interval '-2147483648 months', interval '2147483647 mon struct<> -- !query output org.apache.spark.SparkArithmeticException -[INTERVAL_ARITHMETIC_OVERFLOW] integer overflow. +[ARITHMETIC_OVERFLOW] integer overflow. If necessary set spark.sql.ansi.enabled to "false" (except for ANSI interval type) to bypass this error. -- !query @@ -1751,7 +1751,7 @@ select a - b from values (interval '-2147483648 months', interval '2147483647 mo struct<> -- !query output org.apache.spark.SparkArithmeticException -[INTERVAL_ARITHMETIC_OVERFLOW] integer overflow. Use 'try_subtract' to tolerate overflow and return NULL instead. +[ARITHMETIC_OVERFLOW] integer overflow. If necessary set spark.sql.ansi.enabled to "false" (except for ANSI interval type) to bypass this error. -- !query @@ -1760,7 +1760,7 @@ select b + interval '1 month' from values (interval '-2147483648 months', interv struct<> -- !query output org.apache.spark.SparkArithmeticException -[INTERVAL_ARITHMETIC_OVERFLOW] integer overflow. Use 'try_add' to tolerate overflow and return NULL instead. +[ARITHMETIC_OVERFLOW] integer overflow. If necessary set spark.sql.ansi.enabled to "false" (except for ANSI interval type) to bypass this error. -- !query @@ -1989,7 +1989,7 @@ SELECT (INTERVAL '-178956970-8' YEAR TO MONTH) / -1 struct<> -- !query output org.apache.spark.SparkArithmeticException -[INTERVAL_ARITHMETIC_OVERFLOW] Interval value overflows after being divided by -1. Use 'try_divide' to tolerate overflow and return NULL instead. +[ARITHMETIC_OVERFLOW] Overflow in integral divide. Use 'try_divide' to tolerate overflow and return NULL instead. If necessary set spark.sql.ansi.enabled to "false" (except for ANSI interval type) to bypass this error. == SQL(line 1, position 8) == SELECT (INTERVAL '-178956970-8' YEAR TO MONTH) / -1 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -2001,7 +2001,7 @@ SELECT (INTERVAL '-178956970-8' YEAR TO MONTH) / -1L struct<> -- !query output org.apache.spark.SparkArithmeticException -[INTERVAL_ARITHMETIC_OVERFLOW] Interval value overflows after being divided by -1. Use 'try_divide' to tolerate overflow and return NULL instead. +[ARITHMETIC_OVERFLOW] Overflow in integral divide. Use 'try_divide' to tolerate overflow and return NULL instead. If necessary set spark.sql.ansi.enabled to "false" (except for ANSI interval type) to bypass this error. == SQL(line 1, position 8) == SELECT (INTERVAL '-178956970-8' YEAR TO MONTH) / -1L ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -2047,7 +2047,7 @@ SELECT (INTERVAL '-106751991 04:00:54.775808' DAY TO SECOND) / -1 struct<> -- !query output org.apache.spark.SparkArithmeticException -[INTERVAL_ARITHMETIC_OVERFLOW] Interval value overflows after being divided by -1. Use 'try_divide' to tolerate overflow and return NULL instead. +[ARITHMETIC_OVERFLOW] Overflow in integral divide. Use 'try_divide' to tolerate overflow and return NULL instead. If necessary set spark.sql.ansi.enabled to "false" (except for ANSI interval type) to bypass this error. == SQL(line 1, position 8) == SELECT (INTERVAL '-106751991 04:00:54.775808' DAY TO SECOND) / -1 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -2059,7 +2059,7 @@ SELECT (INTERVAL '-106751991 04:00:54.775808' DAY TO SECOND) / -1L struct<> -- !query output org.apache.spark.SparkArithmeticException -[INTERVAL_ARITHMETIC_OVERFLOW] Interval value overflows after being divided by -1. Use 'try_divide' to tolerate overflow and return NULL instead. +[ARITHMETIC_OVERFLOW] Overflow in integral divide. Use 'try_divide' to tolerate overflow and return NULL instead. If necessary set spark.sql.ansi.enabled to "false" (except for ANSI interval type) to bypass this error. == SQL(line 1, position 8) == SELECT (INTERVAL '-106751991 04:00:54.775808' DAY TO SECOND) / -1L ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/sql/core/src/test/resources/sql-tests/results/postgreSQL/int4.sql.out b/sql/core/src/test/resources/sql-tests/results/postgreSQL/int4.sql.out index 745633e157a..730607e5c16 100755 --- a/sql/core/src/test/resources/sql-tests/results/postgreSQL/int4.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/postgreSQL/int4.sql.out @@ -197,7 +197,7 @@ SELECT '' AS five, i.f1, i.f1 * smallint('2') AS x FROM INT4_TBL i struct<> -- !query output org.apache.spark.SparkArithmeticException -[ARITHMETIC_OVERFLOW] integer overflow. Use 'try_multiply' to tolerate overflow and return NULL instead. If necessary set spark.sql.ansi.enabled to "false" to bypass this error. +[ARITHMETIC_OVERFLOW] integer overflow. Use 'try_multiply' to tolerate overflow and return NULL instead. If necessary set spark.sql.ansi.enabled to "false" (except for ANSI interval type) to bypass this error. == SQL(line 1, position 26) == SELECT '' AS five, i.f1, i.f1 * smallint('2') AS x FROM INT4_TBL i ^^^^^^^^^^^^^^^^^^^^ @@ -220,7 +220,7 @@ SELECT '' AS five, i.f1, i.f1 * int('2') AS x FROM INT4_TBL i struct<> -- !query output org.apache.spark.SparkArithmeticException -[ARITHMETIC_OVERFLOW] integer overflow. Use 'try_multiply' to tolerate overflow and return NULL instead. If necessary set spark.sql.ansi.enabled to "false" to bypass this error. +[ARITHMETIC_OVERFLOW] integer overflow. Use 'try_multiply' to tolerate overflow and return NULL instead. If necessary set spark.sql.ansi.enabled to "false" (except for ANSI interval type) to bypass this error. == SQL(line 1, position 26) == SELECT '' AS five, i.f1, i.f1 * int('2') AS x FROM INT4_TBL i ^^^^^^^^^^^^^^^ @@ -243,7 +243,7 @@ SELECT '' AS five, i.f1, i.f1 + smallint('2') AS x FROM INT4_TBL i struct<> -- !query output org.apache.spark.SparkArithmeticException -[ARITHMETIC_OVERFLOW] integer overflow. Use 'try_add' to tolerate overflow and return NULL instead. If necessary set spark.sql.ansi.enabled to "false" to bypass this error. +[ARITHMETIC_OVERFLOW] integer overflow. Use 'try_add' to tolerate overflow and return NULL instead. If necessary set spark.sql.ansi.enabled to "false" (except for ANSI interval type) to bypass this error. == SQL(line 1, position 26) == SELECT '' AS five, i.f1, i.f1 + smallint('2') AS x FROM INT4_TBL i ^^^^^^^^^^^^^^^^^^^^ @@ -267,7 +267,7 @@ SELECT '' AS five, i.f1, i.f1 + int('2') AS x FROM INT4_TBL i struct<> -- !query output org.apache.spark.SparkArithmeticException -[ARITHMETIC_OVERFLOW] integer overflow. Use 'try_add' to tolerate overflow and return NULL instead. If necessary set spark.sql.ansi.enabled to "false" to bypass this error. +[ARITHMETIC_OVERFLOW] integer overflow. Use 'try_add' to tolerate overflow and return NULL instead. If necessary set spark.sql.ansi.enabled to "false" (except for ANSI interval type) to bypass this error. == SQL(line 1, position 26) == SELECT '' AS five, i.f1, i.f1 + int('2') AS x FROM INT4_TBL i ^^^^^^^^^^^^^^^ @@ -291,7 +291,7 @@ SELECT '' AS five, i.f1, i.f1 - smallint('2') AS x FROM INT4_TBL i struct<> -- !query output org.apache.spark.SparkArithmeticException -[ARITHMETIC_OVERFLOW] integer overflow. Use 'try_subtract' to tolerate overflow and return NULL instead. If necessary set spark.sql.ansi.enabled to "false" to bypass this error. +[ARITHMETIC_OVERFLOW] integer overflow. Use 'try_subtract' to tolerate overflow and return NULL instead. If necessary set spark.sql.ansi.enabled to "false" (except for ANSI interval type) to bypass this error. == SQL(line 1, position 26) == SELECT '' AS five, i.f1, i.f1 - smallint('2') AS x FROM INT4_TBL i ^^^^^^^^^^^^^^^^^^^^ @@ -315,7 +315,7 @@ SELECT '' AS five, i.f1, i.f1 - int('2') AS x FROM INT4_TBL i struct<> -- !query output org.apache.spark.SparkArithmeticException -[ARITHMETIC_OVERFLOW] integer overflow. Use 'try_subtract' to tolerate overflow and return NULL instead. If necessary set spark.sql.ansi.enabled to "false" to bypass this error. +[ARITHMETIC_OVERFLOW] integer overflow. Use 'try_subtract' to tolerate overflow and return NULL instead. If necessary set spark.sql.ansi.enabled to "false" (except for ANSI interval type) to bypass this error. == SQL(line 1, position 26) == SELECT '' AS five, i.f1, i.f1 - int('2') AS x FROM INT4_TBL i ^^^^^^^^^^^^^^^ diff --git a/sql/core/src/test/resources/sql-tests/results/postgreSQL/int8.sql.out b/sql/core/src/test/resources/sql-tests/results/postgreSQL/int8.sql.out index ab77dbe6a60..664263ee8e7 100755 --- a/sql/core/src/test/resources/sql-tests/results/postgreSQL/int8.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/postgreSQL/int8.sql.out @@ -389,7 +389,7 @@ SELECT '' AS three, q1, q2, q1 * q2 AS multiply FROM INT8_TBL struct<> -- !query output org.apache.spark.SparkArithmeticException -[ARITHMETIC_OVERFLOW] long overflow. Use 'try_multiply' to tolerate overflow and return NULL instead. If necessary set spark.sql.ansi.enabled to "false" to bypass this error. +[ARITHMETIC_OVERFLOW] long overflow. Use 'try_multiply' to tolerate overflow and return NULL instead. If necessary set spark.sql.ansi.enabled to "false" (except for ANSI interval type) to bypass this error. == SQL(line 1, position 29) == SELECT '' AS three, q1, q2, q1 * q2 AS multiply FROM INT8_TBL ^^^^^^^ @@ -826,7 +826,7 @@ SELECT bigint((-9223372036854775808)) * bigint((-1)) struct<> -- !query output org.apache.spark.SparkArithmeticException -[ARITHMETIC_OVERFLOW] long overflow. Use 'try_multiply' to tolerate overflow and return NULL instead. If necessary set spark.sql.ansi.enabled to "false" to bypass this error. +[ARITHMETIC_OVERFLOW] long overflow. Use 'try_multiply' to tolerate overflow and return NULL instead. If necessary set spark.sql.ansi.enabled to "false" (except for ANSI interval type) to bypass this error. == SQL(line 1, position 8) == SELECT bigint((-9223372036854775808)) * bigint((-1)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -854,7 +854,7 @@ SELECT bigint((-9223372036854775808)) * int((-1)) struct<> -- !query output org.apache.spark.SparkArithmeticException -[ARITHMETIC_OVERFLOW] long overflow. Use 'try_multiply' to tolerate overflow and return NULL instead. If necessary set spark.sql.ansi.enabled to "false" to bypass this error. +[ARITHMETIC_OVERFLOW] long overflow. Use 'try_multiply' to tolerate overflow and return NULL instead. If necessary set spark.sql.ansi.enabled to "false" (except for ANSI interval type) to bypass this error. == SQL(line 1, position 8) == SELECT bigint((-9223372036854775808)) * int((-1)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -882,7 +882,7 @@ SELECT bigint((-9223372036854775808)) * smallint((-1)) struct<> -- !query output org.apache.spark.SparkArithmeticException -[ARITHMETIC_OVERFLOW] long overflow. Use 'try_multiply' to tolerate overflow and return NULL instead. If necessary set spark.sql.ansi.enabled to "false" to bypass this error. +[ARITHMETIC_OVERFLOW] long overflow. Use 'try_multiply' to tolerate overflow and return NULL instead. If necessary set spark.sql.ansi.enabled to "false" (except for ANSI interval type) to bypass this error. == SQL(line 1, position 8) == SELECT bigint((-9223372036854775808)) * smallint((-1)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/sql/core/src/test/resources/sql-tests/results/postgreSQL/window_part2.sql.out b/sql/core/src/test/resources/sql-tests/results/postgreSQL/window_part2.sql.out index 127e9809169..cb374eb62bd 100644 --- a/sql/core/src/test/resources/sql-tests/results/postgreSQL/window_part2.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/postgreSQL/window_part2.sql.out @@ -222,7 +222,7 @@ from range(9223372036854775804, 9223372036854775807) x struct<> -- !query output org.apache.spark.SparkArithmeticException -[ARITHMETIC_OVERFLOW] long overflow. Use 'try_add' to tolerate overflow and return NULL instead. If necessary set spark.sql.ansi.enabled to "false" to bypass this error. +[ARITHMETIC_OVERFLOW] long overflow. Use 'try_add' to tolerate overflow and return NULL instead. If necessary set spark.sql.ansi.enabled to "false" (except for ANSI interval type) to bypass this error. -- !query @@ -232,7 +232,7 @@ from range(-9223372036854775806, -9223372036854775805) x struct<> -- !query output org.apache.spark.SparkArithmeticException -[ARITHMETIC_OVERFLOW] long overflow. Use 'try_add' to tolerate overflow and return NULL instead. If necessary set spark.sql.ansi.enabled to "false" to bypass this error. +[ARITHMETIC_OVERFLOW] long overflow. Use 'try_add' to tolerate overflow and return NULL instead. If necessary set spark.sql.ansi.enabled to "false" (except for ANSI interval type) to bypass this error. -- !query diff --git a/sql/core/src/test/scala/org/apache/spark/sql/DataFrameAggregateSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/DataFrameAggregateSuite.scala index 958b3e3f53c..81a9294df39 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/DataFrameAggregateSuite.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/DataFrameAggregateSuite.scala @@ -1266,13 +1266,13 @@ class DataFrameAggregateSuite extends QueryTest checkAnswer(df2.select(sum($"year-month")), Nil) } assert(error.toString contains - "SparkArithmeticException: [INTERVAL_ARITHMETIC_OVERFLOW] integer overflow") + "SparkArithmeticException: [ARITHMETIC_OVERFLOW] integer overflow") val error2 = intercept[SparkException] { checkAnswer(df2.select(sum($"day")), Nil) } assert(error2.toString contains - "SparkArithmeticException: [INTERVAL_ARITHMETIC_OVERFLOW] long overflow") + "SparkArithmeticException: [ARITHMETIC_OVERFLOW] long overflow") } test("SPARK-34837: Support ANSI SQL intervals by the aggregate function `avg`") { @@ -1402,13 +1402,13 @@ class DataFrameAggregateSuite extends QueryTest checkAnswer(df2.select(avg($"year-month")), Nil) } assert(error.toString contains - "SparkArithmeticException: [INTERVAL_ARITHMETIC_OVERFLOW] integer overflow") + "SparkArithmeticException: [ARITHMETIC_OVERFLOW] integer overflow") val error2 = intercept[SparkException] { checkAnswer(df2.select(avg($"day")), Nil) } assert(error2.toString contains - "SparkArithmeticException: [INTERVAL_ARITHMETIC_OVERFLOW] long overflow") + "SparkArithmeticException: [ARITHMETIC_OVERFLOW] long overflow") val df3 = intervalData.filter($"class" > 4) val avgDF3 = df3.select(avg($"year-month"), avg($"day")) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org For additional commands, e-mail: commits-h...@spark.apache.org