LuciferYang opened a new pull request, #56278:
URL: https://github.com/apache/spark/pull/56278

   ### What changes were proposed in this pull request?
   
   `If.doGenCode` always emitted, for each branch, an `ev.isNull = 
branchEval.isNull;` assignment after the `boolean ev.isNull = false;` 
declaration. For a non-nullable branch that assignment is `ev.isNull = false;`, 
which is dead (`ev.isNull` is already initialized to `false`). This drops that 
assignment for a non-nullable branch. When the whole `If` is non-nullable (both 
branches non-nullable), it also drops the `boolean ev.isNull = false;` 
declaration and returns `isNull = FalseLiteral`, which lets parent operators 
skip null checks on the result.
   
   The body is refactored into small `Block` values (`isNullDecl` / 
`setTrueIsNull` / `setFalseIsNull`, `EmptyBlock` when not needed). This follows 
the SPARK-56908 non-nullable-children dead-branch pattern and the standard 
non-nullable codegen contract (`isNull = FalseLiteral`).
   
   ### Why are the changes needed?
   
   It removes dead assignments (and, for a non-nullable `If`, the `ev.isNull` 
variable itself), shrinking the generated method. Because `If` is ubiquitous 
and often nested, the `isNull = FalseLiteral` propagation additionally lets 
parent operators drop null checks on a non-nullable `If` result. This helps 
with the JVM 64KB method / constant-pool limits, Janino compile time, and JIT 
work. Part of SPARK-56908.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No. `If.nullable`, `dataType`, and `eval` are unchanged, so results and 
output-schema nullability are identical; only the generated Java is smaller.
   
   ### How was this patch tested?
   
   Existing `ConditionalExpressionSuite` "if" / "case when" (the latter 
delegates single-branch codegen to `If`) and the SPARK-49396 nullability test, 
plus added `checkEvaluation` cases with nullable `BoundReference` branches that 
exercise the both-children-nullable codegen template (the existing 
non-null-literal cases now take the dead-branch-skipping paths instead). 
`checkEvaluation` runs the interpreted and codegen paths; behavior is unchanged.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Code (Claude Opus 4.8)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to