GH-47447: [C++] Fix replace_with_mask for null type arrays#49950
GH-47447: [C++] Fix replace_with_mask for null type arrays#49950AnkitAhlawat7742 wants to merge 5 commits into
Conversation
|
|
|
Hi @raulcd , |
|
Hi @raulcd , |
pitrou
left a comment
There was a problem hiding this comment.
Thanks @AnkitAhlawat7742 for this PR.
Can you add some C++ tests in the existing file vector_replace_test.cc?
You can get some inspiration from the existing TestReplaceBoolean.
| b = pa.array([None], pa.null()) | ||
|
|
||
| result = pc.replace_with_mask(a, True, b) | ||
| assert result.type == pa.null() |
There was a problem hiding this comment.
Ok, but can you test the actual result values?
Something like:
| assert result.type == pa.null() | |
| assert result.type == pa.null() | |
| result.validate(full=True) | |
| assert result.to_pylist() == [None] |
There was a problem hiding this comment.
Updated the Test case
Please have a look
…p and updated the python test with null type
HI @pitrou , |
Fix #47447
Rationale for this change
replace_with_mask crashes when called with null type arrays because a code path incorrectly returns Status::OK() from a function with return type Result<int64_t>.
This PR fixes the issue by ensuring the function returns a valid int64_t value instead of Status::OK() for successful executon
What changes are included in this PR?
Are these changes tested?
Yes, manually run the test case
Are there any user-facing changes?
No
This PR contains a "Critical Fix".
This change fixes a crash in replace_with_mask when operating on null type arrays. The crash occurs due to an invalid successful return path internally constructing Result with Status::OK().
replace_with_maskcrashes when null type inputs are used #47447