From 33ddd2e3fa56212f48c748dee7751eeafe6763f0 Mon Sep 17 00:00:00 2001 From: Joshi Date: Wed, 1 Jul 2015 19:58:41 -0700 Subject: [PATCH] update checkInputColumn to print more info if needed --- .../main/scala/org/apache/spark/ml/util/SchemaUtils.scala | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mllib/src/main/scala/org/apache/spark/ml/util/SchemaUtils.scala b/mllib/src/main/scala/org/apache/spark/ml/util/SchemaUtils.scala index 9252618715625..a5f3e14dac696 100644 --- a/mllib/src/main/scala/org/apache/spark/ml/util/SchemaUtils.scala +++ b/mllib/src/main/scala/org/apache/spark/ml/util/SchemaUtils.scala @@ -34,11 +34,14 @@ object SchemaUtils { * @param colName column name * @param dataType required column data type */ - def checkColumnType(schema: StructType, colName: String, dataType: DataType, + def checkColumnType(schema: StructType, + colName: String, + dataType: DataType, msg: String = ""): Unit = { val actualDataType = schema(colName).dataType + val message = if (msg != null && msg.trim.length > 0) " " + msg else "" require(actualDataType.equals(dataType), - s"Column $colName must be of type $dataType but was actually $actualDataType.$msg") + s"Column $colName must be of type $dataType but was actually $actualDataType.$message") } /**