Skip to content

Commit c8ecc58

Browse files
committed
default to orderbyall given no cols
1 parent 4d3f08e commit c8ecc58

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/snowflake/snowpark/dataframe.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2153,7 +2153,8 @@ def sort(
21532153
-------------
21542154
<BLANKLINE>
21552155
2156-
>>> df.sort(ascending=False).show()
2156+
>>> # Sort by all columns (ORDER BY ALL) - no columns specified
2157+
>>> df.sort([], ascending=False).show()
21572158
-------------
21582159
|"A" |"B" |
21592160
-------------
@@ -2182,13 +2183,9 @@ def sort(
21822183
The aliases ``order_by()`` and ``orderBy()`` have the same behavior.
21832184
"""
21842185

2185-
is_order_by_all = not cols
2186-
21872186
# This code performs additional type checks, run first.
21882187
exprs = self._convert_cols_to_exprs("sort()", *cols)
2189-
if not is_order_by_all:
2190-
if not exprs:
2191-
raise ValueError("sort() needs at least one sort expression.")
2188+
is_order_by_all = not cols or not exprs
21922189

21932190
if (
21942191
is_order_by_all

0 commit comments

Comments
 (0)