You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Further optimize Spark hex byte encoding: reuse input NullBuffer and special-case the no-nulls path #23674
Is your feature request related to a problem or challenge?
Follow-on from review feedback on #23473, which rewrote hex_encode_bytes (datafusion/spark/src/function/math/hex.rs) to write hex digits directly into a single value buffer. Two further optimizations were suggested during review but left out of that PR to keep it focused:
Reuse the input NullBuffer instead of rebuilding one. The current implementation constructs a fresh NullBufferBuilder and calls append_null/append_non_null per row. Since hex encoding is 1:1 with the input rows (a null in maps to a null out), the output nulls are identical to the input's. We could clone the input array's NullBuffer directly instead of rebuilding it. This requires plumbing the input array (or its nulls) through to hex_encode_bytes, which currently only receives an Iterator<Item = Option<T>> and has no access to the underlying NullBuffer.
Special-case the "no nulls" path. When the input NullBuffer is None, there is no need to check each value for Some/None. We could split into two loops — one tight loop for the no-nulls case and one for the has-nulls case.
Activity
alamb commentedon Jul 17, 2026
i think this is a good first issue as it is quite well specified
nerdyinu commentedon Jul 21, 2026
take
Optimize Spark hex null handling (apache#23688)
Optimize Spark hex null handling (apache#23688)