asubiotto opened a new pull request, #27558: URL: https://github.com/apache/datafusion/pull/27558
## Which issue does this PR close? - Closes #27557. ## Rationale for this change Planning repeatedly builds null struct scalars, and each one allocates a child array per field. This makes planning slow for wide structs. ## What changes are included in this PR? `ScalarValue::try_new_null` now builds null structs whose children of equal type share one array. The result is equal to `new_null_array`. Leaf types are keyed by value and nested structs by `Fields` address, so each lookup costs O(1). ## What is the testing strategy for this PR? New unit tests check that the result equals `new_null_array` and that children are shared. Benchmark `equivalence_properties`, measured locally: | Case | `main` | PR | | --- | ---: | ---: | | `wide_struct_fields/230_of_300` | 769 µs | 334 µs | | `wide_struct_fields/230_of_300/ordered_by_s` | 1.09 ms | 512 µs | ## Are there any user-facing changes? No. AI disclosure: written with the help of Claude Code. I have reviewed all of the code. -- 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]
