-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: Arrow setitem segfaults when len > 145 000 #52075
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1634,6 +1634,10 @@ def _replace_with_mask( | |
indices = pa.array(indices, type=pa.int64()) | ||
replacements = replacements.take(indices) | ||
return cls._if_else(mask, replacements, values) | ||
if isinstance(values, pa.ChunkedArray): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could limit it to combine the chunks only when the values have boolean type There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
# GH#52059 replace_with_mask segfaults for chunked array | ||
# https://github.com/apache/arrow/issues/34634 | ||
values = values.combine_chunks() | ||
try: | ||
return pc.replace_with_mask(values, mask, replacements) | ||
except pa.ArrowNotImplementedError: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2368,3 +2368,12 @@ def test_pickle_old_arrowextensionarray(): | |
tm.assert_extension_array_equal(result, expected) | ||
assert result._pa_array == pa.chunked_array(data) | ||
assert not hasattr(result, "_data") | ||
|
||
|
||
def test_setitem_boolean_replace_with_mask_segfault(): | ||
# GH#52059 | ||
N = 145_000 | ||
arr = ArrowExtensionArray(pa.chunked_array([np.ones((N,), dtype=np.bool_)])) | ||
Comment on lines
+2375
to
+2376
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think you need this > 145_000. Based on @lukemanley's report, this just happens for any (also tiny) chunked array. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test did not fail with a smaller size, this was confusing to me as well but could this only get to fail with arrow functionality only There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, that might be a different issue. But so this test is currently not strictly testing the replace_with_mask issue giving invalid return arrays, because it seems the So also with a N of 2, I see the invalid output, the
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using 145_000 causes a segfault on my machine without the change though, so this should be good enough as a test for now? |
||
expected = arr.copy() | ||
arr[np.zeros((N,), dtype=np.bool_)] = False | ||
assert arr._pa_array == expected._pa_array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add the pyarrow issue link here too?
(mentioned in #52059 (comment))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added