Skip to content

Commit 25f7039

Browse files
committed
include partition column in error message
1 parent ce2db28 commit 25f7039

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/PartitioningUtils.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,8 @@ object PartitioningUtils {
284284
val columnValue = columnValueLiteral.eval()
285285
val castedValue = Cast(columnValueLiteral, dataType, Option(timeZone.getID)).eval()
286286
if (validatePartitionColumns && columnValue != null && castedValue == null) {
287-
throw new RuntimeException(s"Failed to cast partition value `$columnValue` to $dataType")
287+
throw new RuntimeException(s"Failed to cast value `$columnValue` to `$dataType` " +
288+
s"for partition column `$columnName`")
288289
}
289290
Literal.create(castedValue, userSpecifiedDataTypes(columnName))
290291
} else {

sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/FileIndexSuite.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class FileIndexSuite extends SharedSQLContext {
108108
val msg = intercept[RuntimeException] {
109109
fileIndex.partitionSpec()
110110
}.getMessage
111-
assert(msg == "Failed to cast partition value `foo` to IntegerType")
111+
assert(msg == "Failed to cast value `foo` to `IntegerType` for partition column `a`")
112112
}
113113

114114
withSQLConf(SQLConf.VALIDATE_PARTITION_COLUMNS.key -> "false") {

0 commit comments

Comments
 (0)