Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions python/ray/data/_internal/arrow_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,9 +539,13 @@ def to_pylist(self) -> List[Any]:
return self._column.to_pylist()

def to_numpy(self, zero_copy_only: bool = False) -> np.ndarray:
# NOTE: Pyarrow < 13.0.0 does not support ``zero_copy_only``
if get_pyarrow_version() < _MIN_PYARROW_VERSION_TO_NUMPY_ZERO_COPY_ONLY:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Might be worth renaming _MIN_PYARROW_VERSION_TO_NUMPY_ZERO_COPY_ONLY to clarify that it only applies to ChunkedArray, but I guess the name would get pretty verbose.

Will defer to you

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_MIN_PYARROW_VERSION_TO_NUMPY_ZERO_COPY_ONLY is single usage at this time, I think we can leave it as it is for now.

return self._column.to_numpy()
if isinstance(
self._column, pyarrow.ChunkedArray
): # NOTE: ChunkedArray in Pyarrow < 13.0.0 does not support ``zero_copy_only``
return self._column.to_numpy()
else:
return self._column.to_numpy(zero_copy_only=zero_copy_only)

return self._column.to_numpy(zero_copy_only=zero_copy_only)

Expand Down
6 changes: 6 additions & 0 deletions python/ray/data/tests/test_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,9 @@ def test_find_partitions_duplicates():
assert partitions[1].to_pydict() == {"value": []} # [1,2)
assert partitions[2].to_pydict() == {"value": [2, 2, 2, 2, 2]} # [2,3)
assert partitions[3].to_pydict() == {"value": []} # >=3


if __name__ == "__main__":
import sys

sys.exit(pytest.main(["-v", __file__]))
1 change: 0 additions & 1 deletion semgrep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ rules:
exclude:
# FIXME: These tests weren't run in CI, and now they're failing.
- "python/ray/data/tests/test_arrow_serialization.py"
- "python/ray/data/tests/test_block.py"
- "python/ray/data/tests/test_hash_shuffle.py"
- "python/ray/data/tests/test_operator_fusion.py"
languages:
Expand Down