Skip to content

Commit

Permalink
[SPARK-50248][SQL] Assign appropriate error condition for `_LEGACY_ER…
Browse files Browse the repository at this point in the history
…ROR_TEMP_2058`: `INVALID_PARTITION_VALUE`

### What changes were proposed in this pull request?

This PR proposes to Integrate `_LEGACY_ERROR_TEMP_2058 ` into `INVALID_PARTITION_VALUE `

### Why are the changes needed?

To improve the error message by assigning proper error condition and SQLSTATE

### Does this PR introduce _any_ user-facing change?

No, only user-facing error message improved

### How was this patch tested?

Updated the existing tests

### Was this patch authored or co-authored using generative AI tooling?

No

Closes apache#48778 from itholic/LEGACY_2058.

Authored-by: Haejoon Lee <[email protected]>
Signed-off-by: Max Gekk <[email protected]>
  • Loading branch information
itholic authored and MaxGekk committed Nov 13, 2024
1 parent 40ffdef commit ede05fa
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
11 changes: 6 additions & 5 deletions common/utils/src/main/resources/error/error-conditions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2950,6 +2950,12 @@
},
"sqlState" : "42601"
},
"INVALID_PARTITION_VALUE" : {
"message" : [
"Failed to cast value <value> to data type <dataType> for partition column <columnName>. Ensure the value matches the expected data type for this partition column."
],
"sqlState" : "42846"
},
"INVALID_PROPERTY_KEY" : {
"message" : [
"<key> is an invalid property key, please use quotes, e.g. SET <key>=<value>."
Expand Down Expand Up @@ -7026,11 +7032,6 @@
"Unable to clear partition directory <path> prior to writing to it."
]
},
"_LEGACY_ERROR_TEMP_2058" : {
"message" : [
"Failed to cast value `<value>` to `<dataType>` for partition column `<columnName>`."
]
},
"_LEGACY_ERROR_TEMP_2059" : {
"message" : [
"End of stream."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -795,11 +795,11 @@ private[sql] object QueryExecutionErrors extends QueryErrorsBase with ExecutionE
def failedToCastValueToDataTypeForPartitionColumnError(
value: String, dataType: DataType, columnName: String): SparkRuntimeException = {
new SparkRuntimeException(
errorClass = "_LEGACY_ERROR_TEMP_2058",
errorClass = "INVALID_PARTITION_VALUE",
messageParameters = Map(
"value" -> value,
"dataType" -> dataType.toString(),
"columnName" -> columnName))
"value" -> toSQLValue(value),
"dataType" -> toSQLType(dataType),
"columnName" -> toSQLId(columnName)))
}

def endOfStreamError(): Throwable = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ class FileIndexSuite extends SharedSparkSession {
exception = intercept[SparkRuntimeException] {
fileIndex.partitionSpec()
},
condition = "_LEGACY_ERROR_TEMP_2058",
parameters = Map("value" -> "foo", "dataType" -> "IntegerType", "columnName" -> "a")
condition = "INVALID_PARTITION_VALUE",
parameters = Map("value" -> "'foo'", "dataType" -> "\"INT\"", "columnName" -> "`a`")
)
}

Expand Down

0 comments on commit ede05fa

Please sign in to comment.