Skip to content

Commit

Permalink
Enforce boolean ascending for dask-cudf sort_values (#9814)
Browse files Browse the repository at this point in the history
It is possible to pass a list of `ascending` booleans to dask-cudf's `sort_values`, which is not yet supported by `quantile_divisions` (which computes divisions for all sort-by columns sorted in ascending order), and can cause undefined behavior.

This small PR adds a check that `ascending` is a boolean before computing quantile divisions; note that this check happens _after_ the single-partition case is handled, as cuDF can handle lists of `ascending` booleans.

Authors:
  - Charles Blackmon-Luca (https://github.com/charlesbluca)

Approvers:
  - GALI PREM SAGAR (https://github.com/galipremsagar)

URL: #9814
  • Loading branch information
charlesbluca authored Dec 7, 2021
1 parent ba3aedb commit a72f19e
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions python/dask_cudf/dask_cudf/sorting.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ def sort_values(
na_position="last",
):
"""Sort by the given list/tuple of column names."""
if not isinstance(ascending, bool):
raise ValueError("ascending must be either True or False")
if na_position not in ("first", "last"):
raise ValueError("na_position must be either 'first' or 'last'")

Expand Down

0 comments on commit a72f19e

Please sign in to comment.