Skip to content

Commit

Permalink
[SPARK-20262][SQL] AssertNotNull should throw NullPointerException
Browse files Browse the repository at this point in the history
  • Loading branch information
rxin committed Apr 8, 2017
1 parent 589f3ed commit 4c16795
Showing 1 changed file with 3 additions and 3 deletions.
Expand Up @@ -989,7 +989,7 @@ case class InitializeJavaBean(beanInstance: Expression, setters: Map[String, Exp
* `Int` field named `i`. Expression `s.i` is nullable because `s` can be null. However, for all
* non-null `s`, `s.i` can't be null.
*/
case class AssertNotNull(child: Expression, walkedTypePath: Seq[String])
case class AssertNotNull(child: Expression, walkedTypePath: Seq[String] = Nil)
extends UnaryExpression with NonSQLExpression {

override def dataType: DataType = child.dataType
Expand All @@ -1005,7 +1005,7 @@ case class AssertNotNull(child: Expression, walkedTypePath: Seq[String])
override def eval(input: InternalRow): Any = {
val result = child.eval(input)
if (result == null) {
throw new RuntimeException(errMsg)
throw new NullPointerException(errMsg)
}
result
}
Expand All @@ -1021,7 +1021,7 @@ case class AssertNotNull(child: Expression, walkedTypePath: Seq[String])
${childGen.code}

if (${childGen.isNull}) {
throw new RuntimeException($errMsgField);
throw new NullPointerException($errMsgField);
}
"""
ev.copy(code = code, isNull = "false", value = childGen.value)
Expand Down

0 comments on commit 4c16795

Please sign in to comment.