Skip to content

fix: try_binary dropped the logical nulls of run and dictionary arrays - #10748

Open
emilk wants to merge 2 commits into
apache:mainfrom
emilk:emilk/fix-try-binary-logical-nulls
Open

fix: try_binary dropped the logical nulls of run and dictionary arrays#10748
emilk wants to merge 2 commits into
apache:mainfrom
emilk:emilk/fix-try-binary-logical-nulls

Conversation

@emilk

@emilk emilk commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

No issue; found while reviewing #10730.

Rationale for this change

try_binary skipped null handling when a.null_count() == 0 && b.null_count() == 0. That is a physical count. A RunArray never has a null buffer of its own, so an array whose values contain nulls took the no-nulls fast path and silently produced a result with no nulls at all:

values [Some(10), None, Some(30)] + [1, 1, 1] => [11, 1, 31]   // row 1 should be null

A DictionaryArray with nullable values has the same problem. binary is unaffected: it has no such fast path.

What changes are included in this PR?

Gate the fast path on is_nullable, which accounts for logical nulls. That check is allowed to be conservative, so an empty union of the logical nulls now falls back to the no-nulls path instead of unwrapping.

Are these changes tested?

Yes, a new test for a RunArray with nulls in its values. It fails on main.

Are there any user-facing changes?

try_binary returns the correct nulls for run and dictionary arrays. No API change.

`null_count` counts physical nulls only. A `RunArray` has no null buffer
of its own, so an array whose values contain nulls took the no-nulls fast
path and produced a result with no nulls at all:

    values [Some(10), None, Some(30)] + [1, 1, 1] => [11, 1, 31]

Gate the fast path on `is_nullable`, which accounts for logical nulls.
That check is allowed to be conservative, so fall back to the no-nulls
path when the union of the logical nulls turns out to be empty, instead
of unwrapping it.
@emilk
emilk marked this pull request as ready for review August 19, 2026 06:41
@github-actions github-actions Bot added arrow Changes to the arrow crate arrow-arith labels Aug 19, 2026
@Jefffrey Jefffrey added the bug label Aug 19, 2026

@Rich-T-kid Rich-T-kid left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is related #10485

Comment thread arrow-arith/src/arity.rs
Comment thread arrow-arith/src/arity.rs
@Jefffrey

Copy link
Copy Markdown
Contributor

another thing to note is try_binary_mut has the same issue

`try_binary_mut` only takes `PrimitiveArray`, whose logical and physical
nulls always coincide, so it cannot drop logical nulls the way
`try_binary` did. Still, gate its fast path on `is_nullable` too, and
fall back to the no-nulls path when the union of the logical nulls comes
out empty, instead of unwrapping it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow Changes to the arrow crate arrow-arith bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants