GH-49888: [C++][Compute] Fix count for run-end encoded arrays with nulls#49908
Merged
pitrou merged 2 commits intoapache:mainfrom May 6, 2026
Merged
GH-49888: [C++][Compute] Fix count for run-end encoded arrays with nulls#49908pitrou merged 2 commits intoapache:mainfrom
pitrou merged 2 commits intoapache:mainfrom
Conversation
Contributor
Author
|
The added tests use a simplified version of the reproducer from the issue. Reproduceimport pyarrow as pa
import pyarrow.compute as pc
array = pa.array([1, None])
encoded = pc.run_end_encode(array)
print(f"plain only_null: ", pc.count(array, mode="only_null"))
print(f"run_end_encode only_null: ", pc.count(encoded, mode="only_null"))Result |
tadeja
reviewed
May 4, 2026
tadeja
reviewed
May 4, 2026
tadeja
suggested changes
May 4, 2026
Contributor
tadeja
left a comment
There was a problem hiding this comment.
Thank you for the fix, @fenfeng9 ! 🌞 A few additional test suggestions from my end as inline comments.
The MinGW64 CI failures look unrelated. There were some overlapping failures on main.
9deb821 to
5fa94cc
Compare
Contributor
Author
|
Thanks for the suggestion. I updated the C++ and Python tests. |
Contributor
Author
|
The original behavior is: Reproduceimport pyarrow as pa
import pyarrow.compute as pc
array = pa.array([1, 1, None, None, None, 2, 2, 2, None, 3])
encoded = pc.run_end_encode(array)
# Logical slice: [None, None, 2, 2, 2, None].
slice_plain = array.slice(3, 6)
slice_encoded = encoded.slice(3, 6)
print("pyarrow:", pa.__version__)
print()
print(f"{'case':<12} {'only_valid':>10} {'only_null':>10} {'all':>6}")
for name, value in [
("plain", array),
("ree", encoded),
("slice plain", slice_plain),
("slice ree", slice_encoded),
]:
print(
f"{name:<12} "
f"{pc.count(value, mode='only_valid').as_py():>10} "
f"{pc.count(value, mode='only_null').as_py():>10} "
f"{pc.count(value, mode='all').as_py():>6}"
)Result |
Contributor
Author
|
The test failures look unrelated. |
pitrou
approved these changes
May 6, 2026
Member
|
And thanks @tadeja for the useful reviewing! |
|
After merging your PR, Conbench analyzed the 0 benchmarking runs that have been run so far on merge-commit 1b3f313. None of the specified runs were found on the Conbench server. The full Conbench report has more details. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
The
countkernel usedGetNullCount(), which reports the physical null count. For run-end encoded arrays, this ignored nulls in the encoded values child.What changes are included in this PR?
Use
ComputeLogicalNullCount()in thecountkernel so run-end encoded arrays are counted correctly. Add C++ and Python tests for this case.Are these changes tested?
Yes.
Are there any user-facing changes?
No.
countkernel miscounts when run-end encoded array contains null #49888