Skip to content

Commit

Permalink
feat: DuckDB dt.weekday (#1795)
Browse files Browse the repository at this point in the history
  • Loading branch information
raisadz authored Jan 11, 2025
1 parent f1b9fd9 commit 0af14cd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions narwhals/_duckdb/expr_dt.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,12 @@ def nanosecond(self) -> DuckDBExpr:
"nanosecond",
returns_scalar=self._compliant_expr._returns_scalar,
)

def weekday(self) -> DuckDBExpr:
from duckdb import FunctionExpression

return self._compliant_expr._from_call(
lambda _input: FunctionExpression("isodow", _input),
"weekday",
returns_scalar=self._compliant_expr._returns_scalar,
)
2 changes: 1 addition & 1 deletion tests/expr_and_series/dt/datetime_attributes_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def test_datetime_attributes(
request.applymarker(pytest.mark.xfail)
if attribute == "date" and "cudf" in str(constructor):
request.applymarker(pytest.mark.xfail)
if "duckdb" in str(constructor) and attribute in ("date", "weekday", "ordinal_day"):
if "duckdb" in str(constructor) and attribute in ("date", "ordinal_day"):
request.applymarker(pytest.mark.xfail)
if "pyspark" in str(constructor):
request.applymarker(pytest.mark.xfail)
Expand Down

0 comments on commit 0af14cd

Please sign in to comment.