[SPARK-20262][SQL] AssertNotNull should throw NullPointerException
## What changes were proposed in this pull request? AssertNotNull currently throws RuntimeException. It should throw NullPointerException, which is more specific. ## How was this patch tested? N/A Author: Reynold Xin <rxin@databricks.com> Closes #17573 from rxin/SPARK-20262.
This commit is contained in:
parent
7577e9c356
commit
e1afc4dcca
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue