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

[Data] Raise ValueError when the data sort key is None #48969

Merged
merged 5 commits into from
Dec 3, 2024
Merged
Changes from 3 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
6 changes: 6 additions & 0 deletions python/ray/data/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -2411,6 +2411,7 @@ def sort(
boundaries: List[Union[int, float]] = None,
) -> "Dataset":
"""Sort the dataset by the specified key column or key function.
The `key` parameter must be specified (i.e., it cannot be `None`).

.. note::
The `descending` parameter must be a boolean, or a list of booleans.
Expand Down Expand Up @@ -2459,7 +2460,12 @@ def sort(

Returns:
A new, sorted :class:`Dataset`.

Raises:
``ValueError``: if the sort key is None.
"""
if key is None:
raise ValueError("The 'key' parameter cannot be None for sorting.")
sort_key = SortKey(key, descending, boundaries)
plan = self._plan.copy()
op = Sort(
Expand Down