Skip to content

Commit

Permalink
Merge pull request #4 from raisadz/duckdb-relational-strip-chars
Browse files Browse the repository at this point in the history
feat: add `strip_chars` to duckdb
  • Loading branch information
MarcoGorelli authored Dec 29, 2024
2 parents a8d303d + e3bca42 commit b122af7
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions narwhals/_duckdb/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,24 @@ def to_uppercase(self) -> DuckDBExpr:
returns_scalar=False,
)

def strip_chars(self, characters: str | None) -> DuckDBExpr:
import string

from duckdb import ConstantExpression
from duckdb import FunctionExpression

return self._compliant_expr._from_call(
lambda _input: FunctionExpression(
"trim",
_input,
ConstantExpression(
string.whitespace if characters is None else characters
),
),
"strip_chars",
returns_scalar=False,
)


class DuckDBExprDateTimeNamespace:
def __init__(self, expr: DuckDBExpr) -> None:
Expand Down

0 comments on commit b122af7

Please sign in to comment.