aboutsummaryrefslogtreecommitdiff
path: root/mllib
diff options
context:
space:
mode:
authorJoshi <rekhajoshm@gmail.com>2015-07-05 12:58:03 -0700
committerJoseph K. Bradley <joseph@databricks.com>2015-07-05 12:58:03 -0700
commitf9c448dce8139e85ac564daa0f7e0325e778cffe (patch)
tree239c3f44564354886c71f65d7234bff2cd6070cb /mllib
parent2b820f2a4bf9b154762e7516a5b0485322799da9 (diff)
downloadspark-f9c448dce8139e85ac564daa0f7e0325e778cffe.tar.gz
spark-f9c448dce8139e85ac564daa0f7e0325e778cffe.tar.bz2
spark-f9c448dce8139e85ac564daa0f7e0325e778cffe.zip
[SPARK-7137] [ML] Update SchemaUtils checkInputColumn to print more info if needed
Author: Joshi <rekhajoshm@gmail.com> Author: Rekha Joshi <rekhajoshm@gmail.com> Closes #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
Diffstat (limited to 'mllib')
-rw-r--r--mllib/src/main/scala/org/apache/spark/ml/util/SchemaUtils.scala9
1 files changed, 7 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 7cd53c6d7e..76f651488a 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
@@ -32,10 +32,15 @@ private[spark] object SchemaUtils {
* @param colName column name
* @param dataType required column data type
*/
- def checkColumnType(schema: StructType, colName: String, dataType: DataType): Unit = {
+ 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.")
+ s"Column $colName must be of type $dataType but was actually $actualDataType.$message")
}
/**