Skip to content

fix(arrow/array): ignore zero-count union appends - #1026

Merged
zeroshade merged 1 commit into
apache:mainfrom
fallintoplace:fix/dense-union-zero-bulk-append
Jul 27, 2026
Merged

fix(arrow/array): ignore zero-count union appends#1026
zeroshade merged 1 commit into
apache:mainfrom
fallintoplace:fix/dense-union-zero-bulk-append

Conversation

@fallintoplace

Copy link
Copy Markdown
Contributor

Rationale for this change

DenseUnionBuilder.AppendNulls(0) and AppendEmptyValues(0) still append a child value even though they add no union entries. That hidden mutation shifts the offset of the next real value and leaves inaccessible child data behind.

What changes are included in this PR?

  • Make non-positive bulk null and empty appends no-ops.
  • Preserve the existing shared-child optimization for positive counts.

Are these changes tested?

Yes. The regression test verifies that both zero-count calls leave the union and child builders empty, then confirms the next real value uses offset zero. The full arrow/array package, assertion build, compute packages, and IPC package also pass.

@fallintoplace
fallintoplace requested a review from zeroshade as a code owner July 25, 2026 20:43

@zeroshade zeroshade left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Verified: `DenseUnionBuilder.AppendNulls`/`AppendEmptyValues` called the child builder once outside the count loop, so a zero count appended no union entry but still advanced the child — I reproduced parent length 0 with child length 1. The `n <= 0` guard is the right fix and brings Dense in line with `SparseUnionBuilder`, which already no-ops on a zero count. LGTM.

@zeroshade
zeroshade merged commit 736b184 into apache:main Jul 27, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants