[SPARK-35333][SQL] Skip object null check in Invoke if possible
### What changes were proposed in this pull request? If `targetObject` is not nullable, we don't need the object null check in `Invoke`. ### Why are the changes needed? small perf improvement ### Does this PR introduce _any_ user-facing change? no ### How was this patch tested? existing tests Closes #32466 from cloud-fan/invoke. Authored-by: Wenchen Fan <wenchen@databricks.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com>
This commit is contained in:
parent
cf2c4ba584
commit
9aa18dfe19
|
@ -414,16 +414,29 @@ case class Invoke(
|
|||
"""
|
||||
}
|
||||
|
||||
val mainEvalCode =
|
||||
code"""
|
||||
|$argCode
|
||||
|${ev.isNull} = $resultIsNull;
|
||||
|if (!${ev.isNull}) {
|
||||
| $evaluate
|
||||
|}
|
||||
|""".stripMargin
|
||||
|
||||
val evalWithNullCheck = if (targetObject.nullable) {
|
||||
code"""
|
||||
|if (!${obj.isNull}) {
|
||||
| $mainEvalCode
|
||||
|}
|
||||
|""".stripMargin
|
||||
} else {
|
||||
mainEvalCode
|
||||
}
|
||||
|
||||
val code = obj.code + code"""
|
||||
boolean ${ev.isNull} = true;
|
||||
$javaType ${ev.value} = ${CodeGenerator.defaultValue(dataType)};
|
||||
if (!${obj.isNull}) {
|
||||
$argCode
|
||||
${ev.isNull} = $resultIsNull;
|
||||
if (!${ev.isNull}) {
|
||||
$evaluate
|
||||
}
|
||||
}
|
||||
$evalWithNullCheck
|
||||
"""
|
||||
ev.copy(code = code)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue