Skip to content

Commit 4d3f08e

Browse files
committed
move type checking to top, preventing bad types from sneaking into AST
1 parent 8a555ef commit 4d3f08e

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/snowflake/snowpark/dataframe.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2183,6 +2183,13 @@ def sort(
21832183
"""
21842184

21852185
is_order_by_all = not cols
2186+
2187+
# This code performs additional type checks, run first.
2188+
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.")
2192+
21862193
if (
21872194
is_order_by_all
21882195
and ascending is not None
@@ -2230,10 +2237,6 @@ def sort(
22302237
order = Ascending() if bool(asc_value) else Descending()
22312238
sort_exprs = [SortByAllOrder(order)]
22322239
else:
2233-
exprs = self._convert_cols_to_exprs("sort()", *cols)
2234-
if not exprs:
2235-
raise ValueError("sort() needs at least one sort expression.")
2236-
22372240
orders = []
22382241
if ascending is not None:
22392242
if isinstance(ascending, (list, tuple)):

0 commit comments

Comments
 (0)