Skip to content

Commit f9c448d

Browse files
rekhajoshmjkbradley
authored andcommitted
[SPARK-7137] [ML] Update SchemaUtils checkInputColumn to print more info if needed
Author: Joshi <[email protected]> Author: Rekha Joshi <[email protected]> Closes apache#5992 from rekhajoshm/fix/SPARK-7137 and squashes the following commits: 8c42b57 [Joshi] update checkInputColumn to print more info if needed 33ddd2e [Joshi] update checkInputColumn to print more info if needed acf3e17 [Joshi] update checkInputColumn to print more info if needed 8993c0e [Joshi] SPARK-7137: Add checkInputColumn back to Params and print more info e3677c9 [Rekha Joshi] Merge pull request #1 from apache/master
1 parent 2b820f2 commit f9c448d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

mllib/src/main/scala/org/apache/spark/ml/util/SchemaUtils.scala

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,15 @@ private[spark] object SchemaUtils {
3232
* @param colName column name
3333
* @param dataType required column data type
3434
*/
35-
def checkColumnType(schema: StructType, colName: String, dataType: DataType): Unit = {
35+
def checkColumnType(
36+
schema: StructType,
37+
colName: String,
38+
dataType: DataType,
39+
msg: String = ""): Unit = {
3640
val actualDataType = schema(colName).dataType
41+
val message = if (msg != null && msg.trim.length > 0) " " + msg else ""
3742
require(actualDataType.equals(dataType),
38-
s"Column $colName must be of type $dataType but was actually $actualDataType.")
43+
s"Column $colName must be of type $dataType but was actually $actualDataType.$message")
3944
}
4045

4146
/**

0 commit comments

Comments
 (0)