Skip to content

Commit bd6c0eb

Browse files
committed
fix: Align fill_null w/ polars
1 parent ecb3767 commit bd6c0eb

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

narwhals/_plan/dummy.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ def over(
124124
order = by, options
125125
return self._from_ir(Over().to_window_expr(self._ir, partition, order))
126126

127+
def sort(self, *, descending: bool = False, nulls_last: bool = False) -> Self:
128+
options = SortOptions(descending=descending, nulls_last=nulls_last)
129+
return self._from_ir(expr.Sort(expr=self._ir, options=options))
130+
127131
def sort_by(
128132
self,
129133
by: DummyExpr | t.Iterable[DummyExpr],
@@ -174,12 +178,11 @@ def fill_null(
174178
strategy: FillNullStrategy | None = None,
175179
limit: int | None = None,
176180
) -> Self:
177-
node: F.FillNullWithStrategy | F.FillNull
178-
if strategy is not None:
179-
node = F.FillNullWithStrategy(strategy=strategy, limit=limit)
180-
else:
181-
node = F.FillNull(value=parse.parse_into_expr_ir(value, str_as_lit=True))
182-
return self._from_ir(node.to_function_expr(self._ir))
181+
if strategy is None:
182+
ir = parse.parse_into_expr_ir(value, str_as_lit=True)
183+
return self._from_ir(F.FillNull().to_function_expr(self._ir, ir))
184+
fill = F.FillNullWithStrategy(strategy=strategy, limit=limit)
185+
return self._from_ir(fill.to_function_expr(self._ir))
183186

184187
def shift(self, n: int) -> Self:
185188
return self._from_ir(F.Shift(n=n).to_function_expr(self._ir))

narwhals/_plan/functions.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
from typing import TYPE_CHECKING
1010

11-
from narwhals._plan.common import ExprIR
1211
from narwhals._plan.common import Function
1312
from narwhals._plan.options import FunctionFlags
1413
from narwhals._plan.options import FunctionOptions
@@ -96,10 +95,6 @@ def __repr__(self) -> str:
9695

9796

9897
class FillNull(Function):
99-
__slots__ = ("value",)
100-
101-
value: ExprIR
102-
10398
@property
10499
def function_options(self) -> FunctionOptions:
105100
return FunctionOptions.elementwise()

0 commit comments

Comments
 (0)