Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-48294][SQL] Handle lowercase in nestedTypeMissingElementTypeError #46623

Closed
wants to merge 1 commit into from
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
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ private[sql] object QueryParsingErrors extends DataTypeErrorsBase {

def nestedTypeMissingElementTypeError(
dataType: String, ctx: PrimitiveDataTypeContext): Throwable = {
dataType match {
dataType.toUpperCase(Locale.ROOT) match {
case "ARRAY" =>
new ParseException(
errorClass = "INCOMPLETE_TYPE_DEFINITION.ARRAY",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,13 @@ class QueryParsingErrorsSuite extends QueryTest with SharedSparkSession with SQL
sqlState = "42K01",
parameters = Map("elementType" -> "<INT>"),
context = ExpectedContext(fragment = "ARRAY", start = 30, stop = 34))
// Create column of array type without specifying element type in lowercase
checkError(
exception = parseException("CREATE TABLE tbl_120691 (col1 array)"),
errorClass = "INCOMPLETE_TYPE_DEFINITION.ARRAY",
sqlState = "42K01",
parameters = Map("elementType" -> "<INT>"),
context = ExpectedContext(fragment = "array", start = 30, stop = 34))
}

test("INCOMPLETE_TYPE_DEFINITION: struct type definition is incomplete") {
Expand Down Expand Up @@ -674,6 +681,12 @@ class QueryParsingErrorsSuite extends QueryTest with SharedSparkSession with SQL
errorClass = "PARSE_SYNTAX_ERROR",
sqlState = "42601",
parameters = Map("error" -> "'<'", "hint" -> ": missing ')'"))
// Create column of struct type without specifying field type in lowercase
checkError(
exception = parseException("CREATE TABLE tbl_120691 (col1 struct)"),
errorClass = "INCOMPLETE_TYPE_DEFINITION.STRUCT",
sqlState = "42K01",
context = ExpectedContext(fragment = "struct", start = 30, stop = 35))
}

test("INCOMPLETE_TYPE_DEFINITION: map type definition is incomplete") {
Expand All @@ -695,6 +708,12 @@ class QueryParsingErrorsSuite extends QueryTest with SharedSparkSession with SQL
errorClass = "PARSE_SYNTAX_ERROR",
sqlState = "42601",
parameters = Map("error" -> "'<'", "hint" -> ": missing ')'"))
// Create column of map type without specifying key/value types in lowercase
checkError(
exception = parseException("SELECT CAST(map('1',2) AS map)"),
errorClass = "INCOMPLETE_TYPE_DEFINITION.MAP",
sqlState = "42K01",
context = ExpectedContext(fragment = "map", start = 26, stop = 28))
}

test("INVALID_ESC: Escape string must contain only one character") {
Expand Down