You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by ma...@apache.org on 2022/11/01 06:38:45 UTC
[spark] branch master updated: [SPARK-40975][SQL] Rename the error class `_LEGACY_ERROR_TEMP_0021` to `UNSUPPORTED_TYPED_LITERAL`
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 9bbc9ee730e [SPARK-40975][SQL] Rename the error class `_LEGACY_ERROR_TEMP_0021` to `UNSUPPORTED_TYPED_LITERAL`
9bbc9ee730e is described below
commit 9bbc9ee730edff23598dad7fab20e398806de967
Author: Max Gekk <ma...@gmail.com>
AuthorDate: Tue Nov 1 09:38:29 2022 +0300
[SPARK-40975][SQL] Rename the error class `_LEGACY_ERROR_TEMP_0021` to `UNSUPPORTED_TYPED_LITERAL`
### What changes were proposed in this pull request?
In the PR, I propose to assign the proper name `UNSUPPORTED_TYPED_LITERAL ` to the legacy error class `_LEGACY_ERROR_TEMP_0021 `, and modify test suite to use `checkError()` which checks the error class name, context and etc.
### Why are the changes needed?
Proper name improves user experience w/ Spark SQL.
### Does this PR introduce _any_ user-facing change?
Yes, the PR changes an user-facing error message.
### How was this patch tested?
By running the modified test suites:
```
$ PYSPARK_PYTHON=python3 build/sbt "sql/testOnly org.apache.spark.sql.SQLQueryTestSuite"
$ build/sbt "test:testOnly *ExpressionParserSuite"
$ build/sbt "test:testOnly *AnalysisSuite"
```
Closes #38448 from MaxGekk/error-class-typed-literal.
Authored-by: Max Gekk <ma...@gmail.com>
Signed-off-by: Max Gekk <ma...@gmail.com>
---
core/src/main/resources/error/error-classes.json | 10 +++++-----
.../org/apache/spark/sql/catalyst/parser/AstBuilder.scala | 6 +++++-
.../scala/org/apache/spark/sql/errors/QueryParsingErrors.scala | 10 +++++++---
.../spark/sql/catalyst/parser/ExpressionParserSuite.scala | 7 +++++--
.../src/test/resources/sql-tests/results/ansi/literals.sql.out | 5 +++--
sql/core/src/test/resources/sql-tests/results/literals.sql.out | 5 +++--
6 files changed, 28 insertions(+), 15 deletions(-)
diff --git a/core/src/main/resources/error/error-classes.json b/core/src/main/resources/error/error-classes.json
index bd449930e3b..1617c88e9fe 100644
--- a/core/src/main/resources/error/error-classes.json
+++ b/core/src/main/resources/error/error-classes.json
@@ -1145,6 +1145,11 @@
}
}
},
+ "UNSUPPORTED_TYPED_LITERAL" : {
+ "message" : [
+ "Literals of the type <unsupportedType> are not supported. Supported types are <supportedTypes>."
+ ]
+ },
"UNTYPED_SCALA_UDF" : {
"message" : [
"You're using untyped Scala UDF, which does not have the input type information. Spark may blindly pass null to the Scala closure with primitive-type argument, and the closure will see the default value of the Java type for the null argument, e.g. `udf((x: Int) => x, IntegerType)`, the result is 0 for null input. To get rid of this error, you could:",
@@ -1253,11 +1258,6 @@
"Cannot parse the INTERVAL value: <value>."
]
},
- "_LEGACY_ERROR_TEMP_0021" : {
- "message" : [
- "Literals of type '<valueType>' are currently not supported."
- ]
- },
"_LEGACY_ERROR_TEMP_0022" : {
"message" : [
"<msg>."
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
index a2518f6b17e..84911bf59c7 100644
--- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
+++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
@@ -2397,7 +2397,11 @@ class AstBuilder extends SqlBaseParserBaseVisitor[AnyRef] with SQLConfHelper wit
s"contains illegal character for hexBinary: $padding$value");
}
case other =>
- throw QueryParsingErrors.literalValueTypeUnsupportedError(other, ctx)
+ throw QueryParsingErrors.literalValueTypeUnsupportedError(
+ unsupportedType = other,
+ supportedTypes =
+ Seq("DATE", "TIMESTAMP_NTZ", "TIMESTAMP_LTZ", "TIMESTAMP", "INTERVAL", "X"),
+ ctx)
}
} catch {
case e: IllegalArgumentException =>
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryParsingErrors.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryParsingErrors.scala
index d5132ad45a6..a17b4e592b2 100644
--- a/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryParsingErrors.scala
+++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryParsingErrors.scala
@@ -234,10 +234,14 @@ private[sql] object QueryParsingErrors extends QueryErrorsBase {
}
def literalValueTypeUnsupportedError(
- valueType: String, ctx: TypeConstructorContext): Throwable = {
+ unsupportedType: String,
+ supportedTypes: Seq[String],
+ ctx: TypeConstructorContext): Throwable = {
new ParseException(
- errorClass = "_LEGACY_ERROR_TEMP_0021",
- messageParameters = Map("valueType" -> valueType),
+ errorClass = "UNSUPPORTED_TYPED_LITERAL",
+ messageParameters = Map(
+ "unsupportedType" -> toSQLType(unsupportedType),
+ "supportedTypes" -> supportedTypes.map(toSQLType).mkString(", ")),
ctx)
}
diff --git a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/ExpressionParserSuite.scala b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/ExpressionParserSuite.scala
index e1316c5b132..884e782736c 100644
--- a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/ExpressionParserSuite.scala
+++ b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/ExpressionParserSuite.scala
@@ -658,8 +658,11 @@ class ExpressionParserSuite extends AnalysisTest {
checkError(
exception = parseException("GEO '(10,-6)'"),
- errorClass = "_LEGACY_ERROR_TEMP_0021",
- parameters = Map("valueType" -> "GEO"),
+ errorClass = "UNSUPPORTED_TYPED_LITERAL",
+ parameters = Map(
+ "unsupportedType" -> "\"GEO\"",
+ "supportedTypes" ->
+ """"DATE", "TIMESTAMP_NTZ", "TIMESTAMP_LTZ", "TIMESTAMP", "INTERVAL", "X""""),
context = ExpectedContext(
fragment = "GEO '(10,-6)'",
start = 0,
diff --git a/sql/core/src/test/resources/sql-tests/results/ansi/literals.sql.out b/sql/core/src/test/resources/sql-tests/results/ansi/literals.sql.out
index 0f205430cf1..108cfd19deb 100644
--- a/sql/core/src/test/resources/sql-tests/results/ansi/literals.sql.out
+++ b/sql/core/src/test/resources/sql-tests/results/ansi/literals.sql.out
@@ -442,9 +442,10 @@ struct<>
-- !query output
org.apache.spark.sql.catalyst.parser.ParseException
{
- "errorClass" : "_LEGACY_ERROR_TEMP_0021",
+ "errorClass" : "UNSUPPORTED_TYPED_LITERAL",
"messageParameters" : {
- "valueType" : "GEO"
+ "supportedTypes" : "\"DATE\", \"TIMESTAMP_NTZ\", \"TIMESTAMP_LTZ\", \"TIMESTAMP\", \"INTERVAL\", \"X\"",
+ "unsupportedType" : "\"GEO\""
},
"queryContext" : [ {
"objectType" : "",
diff --git a/sql/core/src/test/resources/sql-tests/results/literals.sql.out b/sql/core/src/test/resources/sql-tests/results/literals.sql.out
index 0f205430cf1..108cfd19deb 100644
--- a/sql/core/src/test/resources/sql-tests/results/literals.sql.out
+++ b/sql/core/src/test/resources/sql-tests/results/literals.sql.out
@@ -442,9 +442,10 @@ struct<>
-- !query output
org.apache.spark.sql.catalyst.parser.ParseException
{
- "errorClass" : "_LEGACY_ERROR_TEMP_0021",
+ "errorClass" : "UNSUPPORTED_TYPED_LITERAL",
"messageParameters" : {
- "valueType" : "GEO"
+ "supportedTypes" : "\"DATE\", \"TIMESTAMP_NTZ\", \"TIMESTAMP_LTZ\", \"TIMESTAMP\", \"INTERVAL\", \"X\"",
+ "unsupportedType" : "\"GEO\""
},
"queryContext" : [ {
"objectType" : "",
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org