Skip to content

Commit

Permalink
update checkInputColumn to print more info if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
rekhajoshm committed Jul 2, 2015
1 parent acf3e17 commit 33ddd2e
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

/**
Expand Down

0 comments on commit 33ddd2e

Please sign in to comment.