Skip to content

GH-43851: [C++][Compute] Drop logical nulls from union values across containers - #54725

Open
xgbtxy wants to merge 1 commit into
apache:mainfrom
xgbtxy:fix/gh-43851-drop-null-unions
Open

xgbtxy wants to merge 1 commit into
apache:mainfrom
xgbtxy:fix/gh-43851-drop-null-unions

Conversation

@xgbtxy

@xgbtxy xgbtxy commented Oct 20, 2026 •

Copy link
Copy Markdown

Rationale for this change

drop_null checks physical null counts and validity bitmaps, which miss the logical nulls in dense and sparse unions. As a result, it can retain null values or rows across Array, ChunkedArray, RecordBatch and Table inputs.

This addresses the union portion of #43851. REE selection support remains outside this patch; it does not resolve the whole issue.

What changes are included in this PR?

Use logical null counts and is_valid masks for unions across the four input kinds. Keep the existing physical-bitmap paths for other types, including dictionary arrays. A MayHaveLogicalNulls check avoids scanning union values when their children cannot contain nulls.

Regressions cover dense/sparse unions, non-default type codes, slices, empty/all-null inputs, chunk boundaries, and row filtering with both union and ordinary columns.

Are these changes tested?

Windows x64, MSVC 19.44, Release, static Arrow/GTest 1.18.0 test linkage:

  • The same three union regressions fail with unmodified production source and pass with this patch.
  • arrow-compute-vector-selection-test: 170 passed, one pre-existing disabled test. This includes the three union regressions.
  • clang-format 18.1.8 and git diff --check: pass.

The original behavior was also reproduced with PyArrow 26.0.0, using explicit validity filtering and Python row selection as controls. The patched validation above is the native C++ suite.

Are there any user-facing changes?

Logical union nulls are now removed, including the corresponding full rows in RecordBatch/Table inputs.

This PR contains a "Critical Fix" under the incorrect-data criterion: drop_null previously returned rows/values that should have been removed. There are no public API signature changes.

Was AI used for this PR?

Codex generated the implementation and regression tests, performed code review, and ran the local validation described above.

PR code and description written by:

  • Human
  • AI

Reviewed before submission by:

  • Human
  • AI
  • Not reviewed

Copilot AI balanced review requested due to automatic review settings October 20, 2026 14:07

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added the awaiting review Awaiting review label Oct 20, 2026
@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #43851 has been automatically assigned in GitHub to PR creator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants