Skip to content
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

Fix shuffle code to work with pyarrow 13 #8009

Merged
merged 1 commit into from Jul 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions distributed/shuffle/_worker_plugin.py
Expand Up @@ -951,7 +951,7 @@
# bytestream such that it cannot be deserialized anymore
t = pa.Table.from_pandas(df, preserve_index=True)
t = t.sort_by("_worker")
codes = np.asarray(t.select(["_worker"]))[0]
codes = np.asarray(t["_worker"])

Check warning on line 954 in distributed/shuffle/_worker_plugin.py

View check run for this annotation

Codecov / codecov/patch

distributed/shuffle/_worker_plugin.py#L954

Added line #L954 was not covered by tests
Copy link
Member Author

Choose a reason for hiding this comment

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

So before you were converting a single-column Table object to a 2D ndarray of shape (1, n) and then getting the 1D array of shape (n, ) with that indexing operation.
With latest pyarrow, that gives shape (n, 1), and then [0] no longer does the correct thing.

But we can also directly convert the column to a numpy array, and then we directly get a 1D array.

t = t.drop(["_worker"])
del df

Expand Down Expand Up @@ -983,7 +983,7 @@
partitions.sort()
t = t.sort_by(column)

partition = np.asarray(t.select([column]))[0]
partition = np.asarray(t[column])

Check warning on line 986 in distributed/shuffle/_worker_plugin.py

View check run for this annotation

Codecov / codecov/patch

distributed/shuffle/_worker_plugin.py#L986

Added line #L986 was not covered by tests
splits = np.where(partition[1:] != partition[:-1])[0] + 1
splits = np.concatenate([[0], splits])

Expand Down