Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
SPARK-7137: Add checkInputColumn back to Params and print more info
  • Loading branch information
rekhajoshm committed May 7, 2015
commit 8993c0ec4542f3df89d673c1c13111f918037e24
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