Skip to content

Commit

Permalink
[SPARK-7137] [ML] Update SchemaUtils checkInputColumn to print more i…
Browse files Browse the repository at this point in the history
…nfo 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
  • Loading branch information
rekhajoshm authored and jkbradley committed Jul 5, 2015
1 parent 2b820f2 commit f9c448d
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

/**
Expand Down

0 comments on commit f9c448d

Please sign in to comment.