-
-
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 2 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,9 @@ 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 | ||
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.array([True] * N)])) | ||
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. nitpick 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. changed |
||
expected = arr.copy() | ||
arr[np.array([False] * N)] = 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