From 784213c810e563dbb128099bdad6b71661a2f4f8 Mon Sep 17 00:00:00 2001 From: ncclementi Date: Tue, 18 Jun 2024 18:45:30 -0400 Subject: [PATCH] chore: fix polars compiler to not overwrite nulls_first --- ibis/backends/polars/compiler.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ibis/backends/polars/compiler.py b/ibis/backends/polars/compiler.py index c9334577a27fd..ce8de0cce67f6 100644 --- a/ibis/backends/polars/compiler.py +++ b/ibis/backends/polars/compiler.py @@ -227,10 +227,14 @@ def sort(op, **kw): by = list(newcols.keys()) descending = [key.descending for key in op.keys] + # NOT SURE IF THIS IS THE RIGHT THING TO DO + nulls_first = all(key.nulls_first for key in op.keys) try: - lf = lf.sort(by, descending=descending, nulls_last=True) + lf = lf.sort(by, descending=descending, nulls_last=not nulls_first) except TypeError: # pragma: no cover - lf = lf.sort(by, reverse=descending, nulls_last=True) # pragma: no cover + lf = lf.sort( + by, reverse=descending, nulls_last=not nulls_first + ) # pragma: no cover #THIS DOESN'T WORK reverse doesn't exists (?) return lf.drop(*by)