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

   ### What changes were proposed in this pull request?
   
   `CreateNamedStruct.doGenCode` emitted, for every value child, an `if 
(isNull) values[i] = null; else values[i] = value;` block. For a non-nullable 
child the `isNull` branch is statically dead (`eval.isNull` is the constant 
`false`), so this skips it and emits a single `values[i] = value;`. Nullable 
children are unchanged.
   
   This mirrors `GenArrayData.genCodeToCreateArrayData` in the same file, which 
already gates the per-element null write on `!expr.nullable` (so `CreateArray` 
/ `CreateMap` already do this) — `CreateNamedStruct` was the lone holdout.
   
   ### Why are the changes needed?
   
   It removes a dead branch and the unreachable `values[i] = null` write per 
non-nullable field, shrinking the generated method. The win scales with struct 
width (e.g. `struct(*)` over a non-null schema), which 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.
   
   ### How was this patch tested?
   
   Existing `ComplexTypeSuite` (`CreateStruct`, `CreateNamedStruct`, 
SPARK-22693 codegen) and `CodeGenerationSuite` wide-struct tests already 
exercise both the non-nullable child (the new branch) and nullable children via 
`checkEvaluation`, which runs the interpreted and codegen paths. Behavior is 
unchanged — the skipped write targets a slot that `new Object[]` already 
zero-initializes to null — so no new test is added, matching the in-file array 
(`GenArrayData`) convention.
   
   ### 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