From 881fb3c1c5b4c6c5eaf1b8bc7fd1a0e206ee976c Mon Sep 17 00:00:00 2001 From: panbingkun Date: Sat, 19 Nov 2022 18:49:27 +0800 Subject: [PATCH 1/3] [SPARK-41182][SQL] Assign a name to the error class _LEGACY_ERROR_TEMP_1102 --- .../main/resources/error/error-classes.json | 10 +++--- .../sql/errors/QueryCompilationErrors.scala | 6 ++-- .../sql-tests/results/extract.sql.out | 36 +++++++++---------- 3 files changed, 25 insertions(+), 27 deletions(-) diff --git a/core/src/main/resources/error/error-classes.json b/core/src/main/resources/error/error-classes.json index a2d9fa071d0f5..3059a076e80d1 100644 --- a/core/src/main/resources/error/error-classes.json +++ b/core/src/main/resources/error/error-classes.json @@ -1326,6 +1326,11 @@ "grouping()/grouping_id() can only be used with GroupingSets/Cube/Rollup" ] }, + "UNSUPPORTED_LITERAL_FOR_SOURCE_TYPE" : { + "message" : [ + "Literals of the type are currently not supported for the type." + ] + }, "UNSUPPORTED_SAVE_MODE" : { "message" : [ "The save mode is not supported for:" @@ -2195,11 +2200,6 @@ "Invalid value for the '' parameter of function '': .." ] }, - "_LEGACY_ERROR_TEMP_1102" : { - "message" : [ - "Literals of type '' are currently not supported for the type." - ] - }, "_LEGACY_ERROR_TEMP_1103" : { "message" : [ "Unsupported component type in arrays." 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 e6ce12756ca78..15f70a582d08f 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 @@ -1073,10 +1073,10 @@ private[sql] object QueryCompilationErrors extends QueryErrorsBase { def literalTypeUnsupportedForSourceTypeError(field: String, source: Expression): Throwable = { new AnalysisException( - errorClass = "_LEGACY_ERROR_TEMP_1102", + errorClass = "UNSUPPORTED_LITERAL_FOR_SOURCE_TYPE", messageParameters = Map( - "field" -> field, - "srcDataType" -> source.dataType.catalogString)) + "field" -> toSQLId(field), + "sourceDataType" -> toSQLType(source.dataType))) } def arrayComponentTypeUnsupportedError(clz: Class[_]): Throwable = { diff --git a/sql/core/src/test/resources/sql-tests/results/extract.sql.out b/sql/core/src/test/resources/sql-tests/results/extract.sql.out index 1c40f623ea1ce..107ee427ed4da 100644 --- a/sql/core/src/test/resources/sql-tests/results/extract.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/extract.sql.out @@ -317,7 +317,7 @@ select extract(not_supported from c) from t struct<> -- !query output org.apache.spark.sql.AnalysisException -Literals of type 'not_supported' are currently not supported for the string type.; line 1 pos 7 +[UNSUPPORTED_LITERAL_FOR_SOURCE_TYPE] Literals of the type `not_supported` are currently not supported for the "STRING" type.; line 1 pos 7 -- !query @@ -326,7 +326,7 @@ select extract(not_supported from i) from t struct<> -- !query output org.apache.spark.sql.AnalysisException -Literals of type 'not_supported' are currently not supported for the interval year to month type.; line 1 pos 7 +[UNSUPPORTED_LITERAL_FOR_SOURCE_TYPE] Literals of the type `not_supported` are currently not supported for the "INTERVAL YEAR TO MONTH" type.; line 1 pos 7 -- !query @@ -335,8 +335,7 @@ select extract(not_supported from j) from t struct<> -- !query output org.apache.spark.sql.AnalysisException -Literals of type 'not_supported' are currently not supported for the interval day to second type.; line 1 pos 7 - +[UNSUPPORTED_LITERAL_FOR_SOURCE_TYPE] Literals of the type `not_supported` are currently not supported for the "INTERVAL DAY TO SECOND" type.; line 1 pos 7 -- !query select date_part('year', c), date_part('year', ntz), date_part('year', i) from t @@ -649,10 +648,10 @@ struct<> -- !query output org.apache.spark.sql.AnalysisException { - "errorClass" : "_LEGACY_ERROR_TEMP_1102", + "errorClass" : "UNSUPPORTED_LITERAL_FOR_SOURCE_TYPE", "messageParameters" : { - "field" : "not_supported", - "srcDataType" : "string" + "field" : "`not_supported`", + "sourceDataType" : "\"STRING\"" }, "queryContext" : [ { "objectType" : "", @@ -924,7 +923,7 @@ select extract(DAY from interval '2-1' YEAR TO MONTH) struct<> -- !query output org.apache.spark.sql.AnalysisException -Literals of type 'DAY' are currently not supported for the interval year to month type.; line 1 pos 7 +[UNSUPPORTED_LITERAL_FOR_SOURCE_TYPE] Literals of the type `DAY` are currently not supported for the "INTERVAL YEAR TO MONTH" type.; line 1 pos 7 -- !query @@ -934,10 +933,10 @@ struct<> -- !query output org.apache.spark.sql.AnalysisException { - "errorClass" : "_LEGACY_ERROR_TEMP_1102", + "errorClass" : "UNSUPPORTED_LITERAL_FOR_SOURCE_TYPE", "messageParameters" : { - "field" : "DAY", - "srcDataType" : "interval year to month" + "field" : "`DAY`", + "sourceDataType" : "\"INTERVAL YEAR TO MONTH\"" }, "queryContext" : [ { "objectType" : "", @@ -956,10 +955,10 @@ struct<> -- !query output org.apache.spark.sql.AnalysisException { - "errorClass" : "_LEGACY_ERROR_TEMP_1102", + "errorClass" : "UNSUPPORTED_LITERAL_FOR_SOURCE_TYPE", "messageParameters" : { - "field" : "not_supported", - "srcDataType" : "interval year to month" + "field" : "`not_supported`", + "sourceDataType" : "\"INTERVAL YEAR TO MONTH\"" }, "queryContext" : [ { "objectType" : "", @@ -1081,8 +1080,7 @@ select extract(MONTH from interval '123 12:34:56.789123123' DAY TO SECOND) struct<> -- !query output org.apache.spark.sql.AnalysisException -Literals of type 'MONTH' are currently not supported for the interval day to second type.; line 1 pos 7 - +[UNSUPPORTED_LITERAL_FOR_SOURCE_TYPE] Literals of the type `MONTH` are currently not supported for the "INTERVAL DAY TO SECOND" type.; line 1 pos 7 -- !query select date_part('not_supported', interval '123 12:34:56.789123123' DAY TO SECOND) @@ -1091,10 +1089,10 @@ struct<> -- !query output org.apache.spark.sql.AnalysisException { - "errorClass" : "_LEGACY_ERROR_TEMP_1102", + "errorClass" : "UNSUPPORTED_LITERAL_FOR_SOURCE_TYPE", "messageParameters" : { - "field" : "not_supported", - "srcDataType" : "interval day to second" + "field" : "`not_supported`", + "sourceDataType" : "\"INTERVAL DAY TO SECOND\"" }, "queryContext" : [ { "objectType" : "", From 3d7c66fdc5c82e2fc3595a3673efd20e66e954bf Mon Sep 17 00:00:00 2001 From: panbingkun Date: Mon, 21 Nov 2022 09:02:55 +0800 Subject: [PATCH 2/3] [SPARK-41182][SQL] Assign a name to the error class _LEGACY_ERROR_TEMP_1102 --- .../main/resources/error/error-classes.json | 10 +++++----- .../sql/errors/QueryCompilationErrors.scala | 2 +- .../sql-tests/results/extract.sql.out | 18 +++++++++--------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/core/src/main/resources/error/error-classes.json b/core/src/main/resources/error/error-classes.json index 3059a076e80d1..26fe4889b81e3 100644 --- a/core/src/main/resources/error/error-classes.json +++ b/core/src/main/resources/error/error-classes.json @@ -656,6 +656,11 @@ ], "sqlState" : "42000" }, + "INVALID_EXTRACT_FIELD" : { + "message" : [ + "Literals of the type are currently not supported for the type." + ] + }, "INVALID_FIELD_NAME" : { "message" : [ "Field name is invalid: is not a struct." @@ -1326,11 +1331,6 @@ "grouping()/grouping_id() can only be used with GroupingSets/Cube/Rollup" ] }, - "UNSUPPORTED_LITERAL_FOR_SOURCE_TYPE" : { - "message" : [ - "Literals of the type are currently not supported for the type." - ] - }, "UNSUPPORTED_SAVE_MODE" : { "message" : [ "The save mode is not supported for:" 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 15f70a582d08f..b7d8517f7acb9 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 @@ -1073,7 +1073,7 @@ private[sql] object QueryCompilationErrors extends QueryErrorsBase { def literalTypeUnsupportedForSourceTypeError(field: String, source: Expression): Throwable = { new AnalysisException( - errorClass = "UNSUPPORTED_LITERAL_FOR_SOURCE_TYPE", + errorClass = "INVALID_EXTRACT_FIELD", messageParameters = Map( "field" -> toSQLId(field), "sourceDataType" -> toSQLType(source.dataType))) diff --git a/sql/core/src/test/resources/sql-tests/results/extract.sql.out b/sql/core/src/test/resources/sql-tests/results/extract.sql.out index 107ee427ed4da..e408741b05e74 100644 --- a/sql/core/src/test/resources/sql-tests/results/extract.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/extract.sql.out @@ -317,7 +317,7 @@ select extract(not_supported from c) from t struct<> -- !query output org.apache.spark.sql.AnalysisException -[UNSUPPORTED_LITERAL_FOR_SOURCE_TYPE] Literals of the type `not_supported` are currently not supported for the "STRING" type.; line 1 pos 7 +[INVALID_EXTRACT_FIELD] Literals of the type `not_supported` are currently not supported for the "STRING" type.; line 1 pos 7 -- !query @@ -326,7 +326,7 @@ select extract(not_supported from i) from t struct<> -- !query output org.apache.spark.sql.AnalysisException -[UNSUPPORTED_LITERAL_FOR_SOURCE_TYPE] Literals of the type `not_supported` are currently not supported for the "INTERVAL YEAR TO MONTH" type.; line 1 pos 7 +[INVALID_EXTRACT_FIELD] Literals of the type `not_supported` are currently not supported for the "INTERVAL YEAR TO MONTH" type.; line 1 pos 7 -- !query @@ -335,7 +335,7 @@ select extract(not_supported from j) from t struct<> -- !query output org.apache.spark.sql.AnalysisException -[UNSUPPORTED_LITERAL_FOR_SOURCE_TYPE] Literals of the type `not_supported` are currently not supported for the "INTERVAL DAY TO SECOND" type.; line 1 pos 7 +[INVALID_EXTRACT_FIELD] Literals of the type `not_supported` are currently not supported for the "INTERVAL DAY TO SECOND" type.; line 1 pos 7 -- !query select date_part('year', c), date_part('year', ntz), date_part('year', i) from t @@ -648,7 +648,7 @@ struct<> -- !query output org.apache.spark.sql.AnalysisException { - "errorClass" : "UNSUPPORTED_LITERAL_FOR_SOURCE_TYPE", + "errorClass" : "INVALID_EXTRACT_FIELD", "messageParameters" : { "field" : "`not_supported`", "sourceDataType" : "\"STRING\"" @@ -923,7 +923,7 @@ select extract(DAY from interval '2-1' YEAR TO MONTH) struct<> -- !query output org.apache.spark.sql.AnalysisException -[UNSUPPORTED_LITERAL_FOR_SOURCE_TYPE] Literals of the type `DAY` are currently not supported for the "INTERVAL YEAR TO MONTH" type.; line 1 pos 7 +[INVALID_EXTRACT_FIELD] Literals of the type `DAY` are currently not supported for the "INTERVAL YEAR TO MONTH" type.; line 1 pos 7 -- !query @@ -933,7 +933,7 @@ struct<> -- !query output org.apache.spark.sql.AnalysisException { - "errorClass" : "UNSUPPORTED_LITERAL_FOR_SOURCE_TYPE", + "errorClass" : "INVALID_EXTRACT_FIELD", "messageParameters" : { "field" : "`DAY`", "sourceDataType" : "\"INTERVAL YEAR TO MONTH\"" @@ -955,7 +955,7 @@ struct<> -- !query output org.apache.spark.sql.AnalysisException { - "errorClass" : "UNSUPPORTED_LITERAL_FOR_SOURCE_TYPE", + "errorClass" : "INVALID_EXTRACT_FIELD", "messageParameters" : { "field" : "`not_supported`", "sourceDataType" : "\"INTERVAL YEAR TO MONTH\"" @@ -1080,7 +1080,7 @@ select extract(MONTH from interval '123 12:34:56.789123123' DAY TO SECOND) struct<> -- !query output org.apache.spark.sql.AnalysisException -[UNSUPPORTED_LITERAL_FOR_SOURCE_TYPE] Literals of the type `MONTH` are currently not supported for the "INTERVAL DAY TO SECOND" type.; line 1 pos 7 +[INVALID_EXTRACT_FIELD] Literals of the type `MONTH` are currently not supported for the "INTERVAL DAY TO SECOND" type.; line 1 pos 7 -- !query select date_part('not_supported', interval '123 12:34:56.789123123' DAY TO SECOND) @@ -1089,7 +1089,7 @@ struct<> -- !query output org.apache.spark.sql.AnalysisException { - "errorClass" : "UNSUPPORTED_LITERAL_FOR_SOURCE_TYPE", + "errorClass" : "INVALID_EXTRACT_FIELD", "messageParameters" : { "field" : "`not_supported`", "sourceDataType" : "\"INTERVAL DAY TO SECOND\"" From 0e433eb54129bd441d779c4cdcac98caa66775ee Mon Sep 17 00:00:00 2001 From: panbingkun Date: Wed, 23 Nov 2022 22:38:42 +0800 Subject: [PATCH 3/3] [SPARK-41182][SQL] Assign a name to the error class _LEGACY_ERROR_TEMP_1102 --- core/src/main/resources/error/error-classes.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/resources/error/error-classes.json b/core/src/main/resources/error/error-classes.json index b953844d59f1d..82809db8218c5 100644 --- a/core/src/main/resources/error/error-classes.json +++ b/core/src/main/resources/error/error-classes.json @@ -682,7 +682,7 @@ ] }, "INVALID_EXTRACT_FIELD" : { - "message": [ + "message" : [ "Cannot extract from ." ] },