Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions core/src/main/resources/error/error-classes.json
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,11 @@
],
"sqlState" : "42000"
},
"INVALID_EXTRACT_FIELD" : {
"message" : [
"Literals of the type <field> are currently not supported for the <sourceDataType> type."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you make the error message more clear and precise. Let's talk specifically about the invalid extract field.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

]
},
"INVALID_FIELD_NAME" : {
"message" : [
"Field name <fieldName> is invalid: <path> is not a struct."
Expand Down Expand Up @@ -2195,11 +2200,6 @@
"Invalid value for the '<argName>' parameter of function '<funcName>': <invalidValue>.<endingMsg>."
]
},
"_LEGACY_ERROR_TEMP_1102" : {
"message" : [
"Literals of type '<field>' are currently not supported for the <srcDataType> type."
]
},
"_LEGACY_ERROR_TEMP_1103" : {
"message" : [
"Unsupported component type <clz> in arrays."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "INVALID_EXTRACT_FIELD",
messageParameters = Map(
"field" -> field,
"srcDataType" -> source.dataType.catalogString))
"field" -> toSQLId(field),
"sourceDataType" -> toSQLType(source.dataType)))
}

def arrayComponentTypeUnsupportedError(clz: Class[_]): Throwable = {
Expand Down
36 changes: 17 additions & 19 deletions sql/core/src/test/resources/sql-tests/results/extract.sql.out
Original file line number Diff line number Diff line change
Expand Up @@ -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
[INVALID_EXTRACT_FIELD] Literals of the type `not_supported` are currently not supported for the "STRING" type.; line 1 pos 7


-- !query
Expand All @@ -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
[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
Expand All @@ -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

[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
Expand Down Expand Up @@ -649,10 +648,10 @@ struct<>
-- !query output
org.apache.spark.sql.AnalysisException
{
"errorClass" : "_LEGACY_ERROR_TEMP_1102",
"errorClass" : "INVALID_EXTRACT_FIELD",
"messageParameters" : {
"field" : "not_supported",
"srcDataType" : "string"
"field" : "`not_supported`",
"sourceDataType" : "\"STRING\""
},
"queryContext" : [ {
"objectType" : "",
Expand Down Expand Up @@ -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
[INVALID_EXTRACT_FIELD] Literals of the type `DAY` are currently not supported for the "INTERVAL YEAR TO MONTH" type.; line 1 pos 7


-- !query
Expand All @@ -934,10 +933,10 @@ struct<>
-- !query output
org.apache.spark.sql.AnalysisException
{
"errorClass" : "_LEGACY_ERROR_TEMP_1102",
"errorClass" : "INVALID_EXTRACT_FIELD",
"messageParameters" : {
"field" : "DAY",
"srcDataType" : "interval year to month"
"field" : "`DAY`",
"sourceDataType" : "\"INTERVAL YEAR TO MONTH\""
},
"queryContext" : [ {
"objectType" : "",
Expand All @@ -956,10 +955,10 @@ struct<>
-- !query output
org.apache.spark.sql.AnalysisException
{
"errorClass" : "_LEGACY_ERROR_TEMP_1102",
"errorClass" : "INVALID_EXTRACT_FIELD",
"messageParameters" : {
"field" : "not_supported",
"srcDataType" : "interval year to month"
"field" : "`not_supported`",
"sourceDataType" : "\"INTERVAL YEAR TO MONTH\""
},
"queryContext" : [ {
"objectType" : "",
Expand Down Expand Up @@ -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

[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)
Expand All @@ -1091,10 +1089,10 @@ struct<>
-- !query output
org.apache.spark.sql.AnalysisException
{
"errorClass" : "_LEGACY_ERROR_TEMP_1102",
"errorClass" : "INVALID_EXTRACT_FIELD",
"messageParameters" : {
"field" : "not_supported",
"srcDataType" : "interval day to second"
"field" : "`not_supported`",
"sourceDataType" : "\"INTERVAL DAY TO SECOND\""
},
"queryContext" : [ {
"objectType" : "",
Expand Down