This is an automated email from the ASF dual-hosted git repository. maxgekk 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 2c0a206a89f [SPARK-43837][SQL] Assign a name to the error class _LEGACY_ERROR_TEMP_103[1-2] 2c0a206a89f is described below commit 2c0a206a89ff9042a0577a7f5f30fa20fb8c984a Author: panbingkun <pbk1...@gmail.com> AuthorDate: Sun May 28 18:59:20 2023 +0300 [SPARK-43837][SQL] Assign a name to the error class _LEGACY_ERROR_TEMP_103[1-2] ### What changes were proposed in this pull request? The pr aims to assign a name to the error class _LEGACY_ERROR_TEMP_103[1-2]. ### Why are the changes needed? The changes improve the error framework. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? - Update existed UT. - Pass GA. Closes #41346 from panbingkun/SPARK-43837. Authored-by: panbingkun <pbk1...@gmail.com> Signed-off-by: Max Gekk <max.g...@gmail.com> --- core/src/main/resources/error/error-classes.json | 27 +++++++++++------- .../spark/sql/errors/QueryCompilationErrors.scala | 18 +++++++++--- .../spark/sql/DataFrameWindowFramesSuite.scala | 33 ++++++++++++++++++---- 3 files changed, 58 insertions(+), 20 deletions(-) diff --git a/core/src/main/resources/error/error-classes.json b/core/src/main/resources/error/error-classes.json index 3a11001ad9d..c8e11e6e55e 100644 --- a/core/src/main/resources/error/error-classes.json +++ b/core/src/main/resources/error/error-classes.json @@ -909,6 +909,23 @@ ], "sqlState" : "22003" }, + "INVALID_BOUNDARY" : { + "message" : [ + "The boundary <boundary> is invalid: <invalidValue>." + ], + "subClass" : { + "END" : { + "message" : [ + "Expected the value is '0', '<longMaxValue>', '[<intMinValue>, <intMaxValue>]'." + ] + }, + "START" : { + "message" : [ + "Expected the value is '0', '<longMinValue>', '[<intMinValue>, <intMaxValue>]'." + ] + } + } + }, "INVALID_BUCKET_FILE" : { "message" : [ "Invalid bucket file: <path>." @@ -3840,16 +3857,6 @@ "Unable to find the column `<colName>` given [<actualColumns>]." ] }, - "_LEGACY_ERROR_TEMP_1301" : { - "message" : [ - "Boundary start is not a valid integer: <start>." - ] - }, - "_LEGACY_ERROR_TEMP_1302" : { - "message" : [ - "Boundary end is not a valid integer: <end>." - ] - }, "_LEGACY_ERROR_TEMP_1304" : { "message" : [ "Unexpected type <className> of the relation <tableName>." diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryCompilationErrors.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryCompilationErrors.scala index 3cb22491aed..18ace731dd4 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryCompilationErrors.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryCompilationErrors.scala @@ -2877,14 +2877,24 @@ private[sql] object QueryCompilationErrors extends QueryErrorsBase { def invalidBoundaryStartError(start: Long): Throwable = { new AnalysisException( - errorClass = "_LEGACY_ERROR_TEMP_1301", - messageParameters = Map("start" -> start.toString)) + errorClass = "INVALID_BOUNDARY.START", + messageParameters = Map( + "boundary" -> toSQLId("start"), + "invalidValue" -> toSQLValue(start, LongType), + "longMinValue" -> toSQLValue(Long.MinValue, LongType), + "intMinValue" -> toSQLValue(Int.MinValue, IntegerType), + "intMaxValue" -> toSQLValue(Int.MaxValue, IntegerType))) } def invalidBoundaryEndError(end: Long): Throwable = { new AnalysisException( - errorClass = "_LEGACY_ERROR_TEMP_1302", - messageParameters = Map("end" -> end.toString)) + errorClass = "INVALID_BOUNDARY.END", + messageParameters = Map( + "boundary" -> toSQLId("end"), + "invalidValue" -> toSQLValue(end, LongType), + "longMaxValue" -> toSQLValue(Long.MaxValue, LongType), + "intMinValue" -> toSQLValue(Int.MinValue, IntegerType), + "intMaxValue" -> toSQLValue(Int.MaxValue, IntegerType))) } def tableOrViewNotFound(ident: Seq[String]): Throwable = { diff --git a/sql/core/src/test/scala/org/apache/spark/sql/DataFrameWindowFramesSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/DataFrameWindowFramesSuite.scala index 48a3d740559..2a81f7e7c2f 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/DataFrameWindowFramesSuite.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/DataFrameWindowFramesSuite.scala @@ -132,12 +132,33 @@ class DataFrameWindowFramesSuite extends QueryTest with SharedSparkSession { Seq(Row(1, 3), Row(1, 4), Row(2, 2), Row(3, 2), Row(2147483650L, 1), Row(2147483650L, 1)) ) - val e = intercept[AnalysisException]( - df.select( - $"key", - count("key").over( - Window.partitionBy($"value").orderBy($"key").rowsBetween(0, 2147483648L)))) - assert(e.message.contains("Boundary end is not a valid integer: 2147483648")) + checkError( + exception = intercept[AnalysisException]( + df.select( + $"key", + count("key").over( + Window.partitionBy($"value").orderBy($"key").rowsBetween(2147483648L, 0)))), + errorClass = "INVALID_BOUNDARY.START", + parameters = Map( + "invalidValue" -> "2147483648L", + "boundary" -> "`start`", + "intMaxValue" -> "2147483647", + "intMinValue" -> "-2147483648", + "longMinValue" -> "-9223372036854775808L")) + + checkError( + exception = intercept[AnalysisException]( + df.select( + $"key", + count("key").over( + Window.partitionBy($"value").orderBy($"key").rowsBetween(0, 2147483648L)))), + errorClass = "INVALID_BOUNDARY.END", + parameters = Map( + "invalidValue" -> "2147483648L", + "boundary" -> "`end`", + "intMaxValue" -> "2147483647", + "intMinValue" -> "-2147483648", + "longMaxValue" -> "9223372036854775807L")) } test("range between should accept at most one ORDER BY expression when unbounded") { --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org For additional commands, e-mail: commits-h...@spark.apache.org