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
12 changes: 6 additions & 6 deletions core/src/main/resources/error/error-classes.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"message" : [ "Cannot use a mixture of aggregate function and group aggregate pandas UDF" ]
},
"CAST_INVALID_INPUT" : {
"message" : [ "The value <value> of the type <sourceType> cannot be cast to <targetType> because it is malformed. To return NULL instead, use `try_cast`. If necessary set <config> to \"false\" to bypass this error." ],
"message" : [ "The value <value> of the type <sourceType> cannot be cast to <targetType> because it is malformed. Correct the value as per the syntax, or change its target type. To return NULL instead, use `try_cast`. If necessary set <config> to \"false\" to bypass this error." ],
"sqlState" : "42000"
},
"CAST_OVERFLOW" : {
Expand Down Expand Up @@ -55,9 +55,6 @@
"message" : [ "Failed to rename <sourcePath> to <targetPath> as destination already exists" ],
"sqlState" : "22023"
},
"FAILED_SET_ORIGINAL_PERMISSION_BACK" : {
"message" : [ "Failed to set original permission <permission> back to the created path: <path>. Exception: <message>" ]
},
"GRAPHITE_SINK_INVALID_PROTOCOL" : {
"message" : [ "Invalid Graphite protocol: <protocol>" ]
},
Expand Down Expand Up @@ -129,11 +126,11 @@
"sqlState" : "42000"
},
"NON_LITERAL_PIVOT_VALUES" : {
"message" : [ "Literal expressions required for pivot values, found '<expression>'" ],
"message" : [ "Literal expressions required for pivot values, found <expression>." ],
"sqlState" : "42000"
},
"NON_PARTITION_COLUMN" : {
"message" : [ "PARTITION clause cannot contain a non-partition column name: <columnName>" ],
"message" : [ "PARTITION clause cannot contain the non-partition column: <columnName>." ],
"sqlState" : "42000"
},
"PARSE_CHAR_MISSING_LENGTH" : {
Expand All @@ -156,6 +153,9 @@
"message" : [ "Failed to rename as <sourcePath> was not found" ],
"sqlState" : "22023"
},
"RESET_PERMISSION_TO_ORIGINAL" : {
"message" : [ "Failed to set original permission <permission> back to the created path: <path>. Exception: <message>" ]
},
"SECOND_FUNCTION_ARGUMENT_NOT_INTEGER" : {
"message" : [ "The second argument of '<functionName>' function needs to be an integer." ],
"sqlState" : "22023"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ object QueryCompilationErrors extends QueryErrorsBase {
def nonLiteralPivotValError(pivotVal: Expression): Throwable = {
new AnalysisException(
errorClass = "NON_LITERAL_PIVOT_VALUES",
messageParameters = Array(pivotVal.toString))
messageParameters = Array(toSQLExpr(pivotVal)))
}

def pivotValDataTypeMismatchError(pivotVal: Expression, pivotCol: Expression): Throwable = {
Expand Down Expand Up @@ -2371,7 +2371,7 @@ object QueryCompilationErrors extends QueryErrorsBase {
def invalidFieldName(fieldName: Seq[String], path: Seq[String], context: Origin): Throwable = {
new AnalysisException(
errorClass = "INVALID_FIELD_NAME",
messageParameters = Array(fieldName.quoted, path.quoted),
messageParameters = Array(toSQLId(fieldName), toSQLId(path)),
origin = context)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ package org.apache.spark.sql.errors

import java.util.Locale

import org.apache.spark.sql.catalyst.expressions.Literal
import org.apache.spark.sql.catalyst.util.quoteIdentifier
import org.apache.spark.sql.catalyst.expressions.{Expression, Literal}
import org.apache.spark.sql.catalyst.util.{quoteIdentifier, toPrettySQL}
import org.apache.spark.sql.types.{DataType, DoubleType, FloatType}

/**
Expand All @@ -39,6 +39,8 @@ import org.apache.spark.sql.types.{DataType, DoubleType, FloatType}
* For example: "spark.sql.ansi.enabled".
* 6. Any values of datasource options or SQL configs shall be double quoted.
* For example: "true", "CORRECTED".
* 7. SQL expressions shall be wrapped by double quotes.
* For example: "earnings + 1".
*/
trait QueryErrorsBase {
// Converts an error class parameter to its SQL representation
Expand Down Expand Up @@ -84,4 +86,8 @@ trait QueryErrorsBase {
def toDSOption(option: String): String = {
quoteByDefault(option)
}

def toSQLExpr(e: Expression): String = {
quoteByDefault(toPrettySQL(e))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1720,7 +1720,7 @@ object QueryExecutionErrors extends QueryErrorsBase {
permission: FsPermission,
path: Path,
e: Throwable): Throwable = {
new SparkSecurityException(errorClass = "FAILED_SET_ORIGINAL_PERMISSION_BACK",
new SparkSecurityException(errorClass = "RESET_PERMISSION_TO_ORIGINAL",
Array(permission.toString, path.toString, e.getMessage))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,8 @@ class StructTypeSuite extends SparkFunSuite with SQLHelper {
var e = intercept[AnalysisException] {
check(Seq("S1", "S12", "S123"), None)
}
assert(e.getMessage.contains("Field name S1.S12.S123 is invalid: s1.s12 is not a struct"))
assert(e.getMessage.contains(
"Field name `S1`.`S12`.`S123` is invalid: `s1`.`s12` is not a struct"))

// ambiguous name
e = intercept[AnalysisException] {
Expand All @@ -333,17 +334,19 @@ class StructTypeSuite extends SparkFunSuite with SQLHelper {
e = intercept[AnalysisException] {
check(Seq("m1", "key"), None)
}
assert(e.getMessage.contains("Field name m1.key is invalid: m1 is not a struct"))
assert(e.getMessage.contains("Field name `m1`.`key` is invalid: `m1` is not a struct"))
checkCollection(Seq("m1", "key"), Some(Seq("m1") -> StructField("key", IntegerType, false)))
checkCollection(Seq("M1", "value"), Some(Seq("m1") -> StructField("value", IntegerType)))
e = intercept[AnalysisException] {
checkCollection(Seq("M1", "key", "name"), None)
}
assert(e.getMessage.contains("Field name M1.key.name is invalid: m1.key is not a struct"))
assert(e.getMessage.contains(
"Field name `M1`.`key`.`name` is invalid: `m1`.`key` is not a struct"))
e = intercept[AnalysisException] {
checkCollection(Seq("M1", "value", "name"), None)
}
assert(e.getMessage.contains("Field name M1.value.name is invalid: m1.value is not a struct"))
assert(e.getMessage.contains(
"Field name `M1`.`value`.`name` is invalid: `m1`.`value` is not a struct"))

// map of struct
checkCollection(Seq("M2", "key", "A"),
Expand All @@ -355,24 +358,25 @@ class StructTypeSuite extends SparkFunSuite with SQLHelper {
e = intercept[AnalysisException] {
checkCollection(Seq("m2", "key", "A", "name"), None)
}
assert(e.getMessage.contains("Field name m2.key.A.name is invalid: m2.key.a is not a struct"))
assert(e.getMessage.contains(
"Field name `m2`.`key`.`A`.`name` is invalid: `m2`.`key`.`a` is not a struct"))
e = intercept[AnalysisException] {
checkCollection(Seq("M2", "value", "b", "name"), None)
}
assert(e.getMessage.contains(
"Field name M2.value.b.name is invalid: m2.value.b is not a struct"))
"Field name `M2`.`value`.`b`.`name` is invalid: `m2`.`value`.`b` is not a struct"))

// simple array type
e = intercept[AnalysisException] {
check(Seq("A1", "element"), None)
}
assert(e.getMessage.contains("Field name A1.element is invalid: a1 is not a struct"))
assert(e.getMessage.contains("Field name `A1`.`element` is invalid: `a1` is not a struct"))
checkCollection(Seq("A1", "element"), Some(Seq("a1") -> StructField("element", IntegerType)))
e = intercept[AnalysisException] {
checkCollection(Seq("A1", "element", "name"), None)
}
assert(e.getMessage.contains(
"Field name A1.element.name is invalid: a1.element is not a struct"))
"Field name `A1`.`element`.`name` is invalid: `a1`.`element` is not a struct"))

// array of struct
checkCollection(Seq("A2", "element", "C"),
Expand All @@ -382,7 +386,7 @@ class StructTypeSuite extends SparkFunSuite with SQLHelper {
checkCollection(Seq("a2", "element", "C", "name"), None)
}
assert(e.getMessage.contains(
"Field name a2.element.C.name is invalid: a2.element.c is not a struct"))
"Field name `a2`.`element`.`C`.`name` is invalid: `a2`.`element`.`c` is not a struct"))
}

test("SPARK-36807: Merge ANSI interval types to a tightest common type") {
Expand Down
Loading