diff --git a/common/utils/src/main/resources/error/error-conditions.json b/common/utils/src/main/resources/error/error-conditions.json index b3c92a9f2b9d1..553d085f88627 100644 --- a/common/utils/src/main/resources/error/error-conditions.json +++ b/common/utils/src/main/resources/error/error-conditions.json @@ -2950,6 +2950,12 @@ }, "sqlState" : "42601" }, + "INVALID_PARTITION_VALUE" : { + "message" : [ + "Failed to cast value to data type for partition column . Ensure the value matches the expected data type for this partition column." + ], + "sqlState" : "42846" + }, "INVALID_PROPERTY_KEY" : { "message" : [ " is an invalid property key, please use quotes, e.g. SET =." @@ -7026,11 +7032,6 @@ "Unable to clear partition directory prior to writing to it." ] }, - "_LEGACY_ERROR_TEMP_2058" : { - "message" : [ - "Failed to cast value `` to `` for partition column ``." - ] - }, "_LEGACY_ERROR_TEMP_2059" : { "message" : [ "End of stream." diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala index 0aa21a4d79c78..0e3f37d8d6fb5 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala @@ -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 = { diff --git a/sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/FileIndexSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/FileIndexSuite.scala index e9f78f9f598e1..33b4cc1d2e7f2 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/FileIndexSuite.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/FileIndexSuite.scala @@ -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`") ) }