Skip to content

Commit

Permalink
SPARK-7137: Add checkInputColumn back to Params and print more info
Browse files Browse the repository at this point in the history
  • Loading branch information
rekhajoshm committed May 7, 2015
1 parent e3677c9 commit 8993c0e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion mllib/src/main/scala/org/apache/spark/ml/param/params.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ import scala.annotation.varargs
import scala.collection.mutable

import org.apache.spark.annotation.AlphaComponent
import org.apache.spark.ml.util.Identifiable
import org.apache.spark.ml.util.{SchemaUtils, Identifiable}
import org.apache.spark.sql.types.{DataType, StructType}

/**
* :: AlphaComponent ::
Expand Down Expand Up @@ -380,6 +381,18 @@ trait Params extends Identifiable with Serializable {
this
}

/**
* Check whether the given schema contains an input column.
* @param colName Input column name
* @param dataType Input column DataType
*/
protected def checkInputColumn(schema: StructType, colName: String, dataType: DataType): Unit = {
val actualDataType = schema(colName).dataType
SchemaUtils.checkColumnType(schema, colName, dataType)
require(actualDataType.equals(dataType), s"Input column Name: $colName Description: ${getParam(colName)}")
}


/**
* Gets the default value of a parameter.
*/
Expand Down

0 comments on commit 8993c0e

Please sign in to comment.