Skip to content
Merged
Changes from 2 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
12 changes: 6 additions & 6 deletions src/snowflake/snowpark/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -2153,7 +2153,8 @@ def sort(
-------------
<BLANKLINE>

>>> df.sort(ascending=False).show()
>>> # Sort by all columns (ORDER BY ALL) - no columns specified
>>> df.sort([], ascending=False).show()
-------------
|"A" |"B" |
-------------
Expand Down Expand Up @@ -2182,7 +2183,10 @@ def sort(
The aliases ``order_by()`` and ``orderBy()`` have the same behavior.
"""

is_order_by_all = not cols
# This code performs additional type checks, run first.
exprs = self._convert_cols_to_exprs("sort()", *cols)
is_order_by_all = not cols or not exprs

if (
is_order_by_all
and ascending is not None
Expand Down Expand Up @@ -2230,10 +2234,6 @@ def sort(
order = Ascending() if bool(asc_value) else Descending()
sort_exprs = [SortByAllOrder(order)]
else:
exprs = self._convert_cols_to_exprs("sort()", *cols)
if not exprs:
raise ValueError("sort() needs at least one sort expression.")

orders = []
if ascending is not None:
if isinstance(ascending, (list, tuple)):
Expand Down
Loading