Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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 @@ -1140,6 +1140,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:",
Expand Down Expand Up @@ -1248,11 +1253,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>."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Copy link
Contributor

Choose a reason for hiding this comment

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

What's X? Hexadecimal?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe a lowercase hexadecimal would be less confusing?

Copy link
Member Author

@MaxGekk MaxGekk Oct 31, 2022

Choose a reason for hiding this comment

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

Here, I pointed out the exact keyword that can be used in the typed literals, see

The syntax is:

Copy link
Member Author

Choose a reason for hiding this comment

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

We could give a hint to user like X hexadecimal

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you mean "X" -> "X hexadecimal" ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, but I would like it as is. Inconsistency confuses always. If we point out supported "types" in typed literals, we should show supported words only.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree with you, "X hexadecimal" looks a little strange

ctx)
}
} catch {
case e: IllegalArgumentException =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" : "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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\"",
Copy link
Contributor

Choose a reason for hiding this comment

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

isn't it a constant list? does it need to be a parameter?

Copy link
Member Author

@MaxGekk MaxGekk Nov 1, 2022

Choose a reason for hiding this comment

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

It depends on implementation, and we might support more in the future. Having the list in the source code can give the following benefits:

  1. The list of parameters might be formatted in different ways ( as a foldable or drop-down list) by frontend tools.
  2. The error classes can be re-used from another places with different list.
  3. More likely, devs will not forget to update the list in source code.
  4. If the list will be in the JSON file, tech editors might forget to edit it or accidentally modify it.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it should be a parameter, unless UNSUPPORTED_TYPED_LITERAL will only be used in this scenario

"unsupportedType" : "\"GEO\""
},
"queryContext" : [ {
"objectType" : "",
Expand Down