Skip to content

Commit

Permalink
feat: DuckDB dt.ordinal_day (#1796)
Browse files Browse the repository at this point in the history
  • Loading branch information
raisadz authored Jan 11, 2025
1 parent 0af14cd commit a729b3e
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 @@ -102,3 +102,12 @@ def weekday(self) -> DuckDBExpr:
"weekday",
returns_scalar=self._compliant_expr._returns_scalar,
)

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

return self._compliant_expr._from_call(
lambda _input: FunctionExpression("dayofyear", _input),
"ordinal_day",
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", "ordinal_day"):
if "duckdb" in str(constructor) and attribute in ("date"):
request.applymarker(pytest.mark.xfail)
if "pyspark" in str(constructor):
request.applymarker(pytest.mark.xfail)
Expand Down

0 comments on commit a729b3e

Please sign in to comment.