Skip to content

Commit

Permalink
simplify is_in
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed Jan 9, 2025
1 parent df1386e commit c7b3080
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions narwhals/_duckdb/expr.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

import functools
from typing import TYPE_CHECKING
from typing import Any
from typing import Callable
Expand Down Expand Up @@ -506,11 +505,7 @@ def is_in(self, other: Sequence[Any]) -> Self:
from duckdb import ConstantExpression

return self._from_call(
lambda _input: functools.reduce(
lambda x, y: x | _input.isin(ConstantExpression(y)),
other[1:],
_input.isin(ConstantExpression(other[0])),
),
lambda _input: _input.isin(*[ConstantExpression(x) for x in other]),
"is_in",
returns_scalar=self._returns_scalar,
)
Expand Down

0 comments on commit c7b3080

Please sign in to comment.