Repository navigation
Fix null sorting for single partition dataframes - #8225
Conversation
|
I'm also realizing now that null handling in general seems to fly in the face of the dask/dask/dataframe/shuffle.py Lines 106 to 108 in ba29ba3 We are essentially setting the output's Does this kwarg have a specific reason for being here - i.e. is it important that we uphold it? I would assume no since these changes haven't seemed to break anything within Dask, but am unsure of if this behavior will cause user confusion. EDIT: Another reason this question is relevant is because if we don't care much about the behavior of |
|
My understanding is that |
|
My bad, I mean to say that dask/dask/dataframe/shuffle.py Lines 413 to 414 in a285509 There is a chance that If it's okay that we don't match the |
| if len(divisions) == 2: | ||
| return df.repartition(npartitions=1).map_partitions( | ||
| M.sort_values, by, ascending=ascending, na_position=na_position | ||
| ) |
There was a problem hiding this comment.
This seems like a simpler way of handling the edge case where sort_values needs to repartition to a single partition; rather than attempt to rearrange_by_divisions and make wasteful calls to set_partitions_pre (which would just assign all rows to the same single partition), we just immediately repartition and proceed with the sort.
With #8167, we now remove duplicates from
divisionswhen we are usingrearrange_by_divisionsfor sorting purposes. One case that wasn't considered here was the sorting of a single partition dataframe with nulls - in this case, it is possible forlen(divisions) == 1, which can cause all sorts of problems such as passingnpartitions=1torearrange_by_columnand assigning rows to non-existent partitions inset_partitions_pre.This PR adds handling for the following cases:
df.npartitions == 1; we now callmap_partitions(M.sort_values, ...)and skip Dask'ssort_valuesaltogetherlen(divisions) == 2before dropping duplicates; this implies that we are going to repartition to a single partition, which can be done usingrepartitionwithout enteringrearrange_by_divisionsWith these changes, we should avoid the failing cases listed above.
black dask/flake8 dask/isort dask