Skip to content
Snippets Groups Projects
Commit c491e2ed authored by setjet's avatar setjet Committed by Xiao Li
Browse files

[SPARK-20873][SQL] Improve the error message for unsupported Column Type

## What changes were proposed in this pull request?
Upon encountering an invalid columntype, the column type object is printed, rather than the type.
This  change improves this by outputting its name.

## How was this patch tested?
Added a simple  unit test to verify the contents of the raised exception

Author: setjet <rubenljanssen@gmail.com>

Closes #18097 from setjet/spark-20873.
parent ae33abf7
No related branches found
No related tags found
No related merge requests found
......@@ -684,7 +684,7 @@ private[columnar] object ColumnType {
case struct: StructType => STRUCT(struct)
case udt: UserDefinedType[_] => apply(udt.sqlType)
case other =>
throw new Exception(s"Unsupported type: $other")
throw new Exception(s"Unsupported type: ${other.simpleString}")
}
}
}
......@@ -144,4 +144,18 @@ class ColumnTypeSuite extends SparkFunSuite with Logging {
ColumnType(DecimalType(19, 0))
}
}
test("show type name in type mismatch error") {
val invalidType = new DataType {
override def defaultSize: Int = 1
override private[spark] def asNullable: DataType = this
override def typeName: String = "invalid type name"
}
val message = intercept[java.lang.Exception] {
ColumnType(invalidType)
}.getMessage
assert(message.contains("Unsupported type: invalid type name"))
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment