Skip to content

Commit

Permalink
refactor(python): Simplify rust side of datetime (#19459)
Browse files Browse the repository at this point in the history
  • Loading branch information
eitsupi authored Oct 26, 2024
1 parent 7a2f547 commit e058bd3
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions crates/polars-python/src/functions/lazy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ pub fn cum_reduce(lambda: PyObject, exprs: Vec<PyExpr>) -> PyExpr {
}

#[pyfunction]
#[pyo3(signature = (year, month, day, hour=None, minute=None, second=None, microsecond=None, time_unit=Wrap(TimeUnit::Microseconds), time_zone=None, ambiguous=None))]
#[pyo3(signature = (year, month, day, hour=None, minute=None, second=None, microsecond=None, time_unit=Wrap(TimeUnit::Microseconds), time_zone=None, ambiguous=PyExpr::from(dsl::lit(String::from("raise")))))]
pub fn datetime(
year: PyExpr,
month: PyExpr,
Expand All @@ -263,15 +263,13 @@ pub fn datetime(
microsecond: Option<PyExpr>,
time_unit: Wrap<TimeUnit>,
time_zone: Option<Wrap<TimeZone>>,
ambiguous: Option<PyExpr>,
ambiguous: PyExpr,
) -> PyExpr {
let year = year.inner;
let month = month.inner;
let day = day.inner;
set_unwrapped_or_0!(hour, minute, second, microsecond);
let ambiguous = ambiguous
.map(|e| e.inner)
.unwrap_or(dsl::lit(String::from("raise")));
let ambiguous = ambiguous.inner;
let time_unit = time_unit.0;
let time_zone = time_zone.map(|x| x.0);
let args = DatetimeArgs {
Expand Down

0 comments on commit e058bd3

Please sign in to comment.