Skip to content

Commit a14d73e

Browse files
committed
[SPARK-52042][SQL] Fix an error of supported typed literals
### What changes were proposed in this pull request? In the PR, I propose to fix the list of supported typed literals in the error message, for example: ```sql [UNSUPPORTED_TYPED_LITERAL] Literals of the type "LOCALTIME" are not supported. Supported types are "DATE", "TIMESTAMP_NTZ", "TIMESTAMP_LTZ", "TIMESTAMP", "INTERVAL", "X". SQLSTATE: 0A000 == SQL (line 1, position 8) == SELECT localtime'12:30:41' ``` The error message does not include `TIME` which was added by apache#50228. ### Why are the changes needed? To don't confuse users regarding the supported typed literals. ### Does this PR introduce _any_ user-facing change? No, it shouldn't. ### How was this patch tested? By running the modified test suites: ``` $ build/sbt "sql/testOnly org.apache.spark.sql.SQLQueryTestSuite -- -z literals.sql" $ build/sbt "test:testOnly *ExpressionParserSuite" ``` ### Was this patch authored or co-authored using generative AI tooling? No. Closes apache#50834 from MaxGekk/fix-time-literal-error. Authored-by: Max Gekk <[email protected]> Signed-off-by: Max Gekk <[email protected]>
1 parent 9831552 commit a14d73e

File tree

6 files changed

+6
-6
lines changed

6 files changed

+6
-6
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3439,7 +3439,7 @@ class AstBuilder extends DataTypeAstBuilder
34393439
throw QueryParsingErrors.literalValueTypeUnsupportedError(
34403440
unsupportedType = ctx.literalType.getText,
34413441
supportedTypes =
3442-
Seq("DATE", "TIMESTAMP_NTZ", "TIMESTAMP_LTZ", "TIMESTAMP", "INTERVAL", "X"),
3442+
Seq("DATE", "TIMESTAMP_NTZ", "TIMESTAMP_LTZ", "TIMESTAMP", "INTERVAL", "X", "TIME"),
34433443
ctx)
34443444
}
34453445
}

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/ExpressionParserSuite.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ class ExpressionParserSuite extends AnalysisTest {
705705
parameters = Map(
706706
"unsupportedType" -> "\"GEO\"",
707707
"supportedTypes" ->
708-
""""DATE", "TIMESTAMP_NTZ", "TIMESTAMP_LTZ", "TIMESTAMP", "INTERVAL", "X""""),
708+
""""DATE", "TIMESTAMP_NTZ", "TIMESTAMP_LTZ", "TIMESTAMP", "INTERVAL", "X", "TIME""""),
709709
context = ExpectedContext(
710710
fragment = "GEO '(10,-6)'",
711711
start = 0,

sql/core/src/test/resources/sql-tests/analyzer-results/literals.sql.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ org.apache.spark.sql.catalyst.parser.ParseException
402402
"errorClass" : "UNSUPPORTED_TYPED_LITERAL",
403403
"sqlState" : "0A000",
404404
"messageParameters" : {
405-
"supportedTypes" : "\"DATE\", \"TIMESTAMP_NTZ\", \"TIMESTAMP_LTZ\", \"TIMESTAMP\", \"INTERVAL\", \"X\"",
405+
"supportedTypes" : "\"DATE\", \"TIMESTAMP_NTZ\", \"TIMESTAMP_LTZ\", \"TIMESTAMP\", \"INTERVAL\", \"X\", \"TIME\"",
406406
"unsupportedType" : "\"GEO\""
407407
},
408408
"queryContext" : [ {

sql/core/src/test/resources/sql-tests/analyzer-results/nonansi/literals.sql.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ org.apache.spark.sql.catalyst.parser.ParseException
402402
"errorClass" : "UNSUPPORTED_TYPED_LITERAL",
403403
"sqlState" : "0A000",
404404
"messageParameters" : {
405-
"supportedTypes" : "\"DATE\", \"TIMESTAMP_NTZ\", \"TIMESTAMP_LTZ\", \"TIMESTAMP\", \"INTERVAL\", \"X\"",
405+
"supportedTypes" : "\"DATE\", \"TIMESTAMP_NTZ\", \"TIMESTAMP_LTZ\", \"TIMESTAMP\", \"INTERVAL\", \"X\", \"TIME\"",
406406
"unsupportedType" : "\"GEO\""
407407
},
408408
"queryContext" : [ {

sql/core/src/test/resources/sql-tests/results/literals.sql.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ org.apache.spark.sql.catalyst.parser.ParseException
454454
"errorClass" : "UNSUPPORTED_TYPED_LITERAL",
455455
"sqlState" : "0A000",
456456
"messageParameters" : {
457-
"supportedTypes" : "\"DATE\", \"TIMESTAMP_NTZ\", \"TIMESTAMP_LTZ\", \"TIMESTAMP\", \"INTERVAL\", \"X\"",
457+
"supportedTypes" : "\"DATE\", \"TIMESTAMP_NTZ\", \"TIMESTAMP_LTZ\", \"TIMESTAMP\", \"INTERVAL\", \"X\", \"TIME\"",
458458
"unsupportedType" : "\"GEO\""
459459
},
460460
"queryContext" : [ {

sql/core/src/test/resources/sql-tests/results/nonansi/literals.sql.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ org.apache.spark.sql.catalyst.parser.ParseException
454454
"errorClass" : "UNSUPPORTED_TYPED_LITERAL",
455455
"sqlState" : "0A000",
456456
"messageParameters" : {
457-
"supportedTypes" : "\"DATE\", \"TIMESTAMP_NTZ\", \"TIMESTAMP_LTZ\", \"TIMESTAMP\", \"INTERVAL\", \"X\"",
457+
"supportedTypes" : "\"DATE\", \"TIMESTAMP_NTZ\", \"TIMESTAMP_LTZ\", \"TIMESTAMP\", \"INTERVAL\", \"X\", \"TIME\"",
458458
"unsupportedType" : "\"GEO\""
459459
},
460460
"queryContext" : [ {

0 commit comments

Comments
 (0)