Skip to content

Commit

Permalink
perf: speed up offset_by when a single offset is passed (#15493)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli authored Apr 6, 2024
1 parent c7910b2 commit 87b84c9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions crates/polars-plan/src/dsl/function_expr/temporal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,12 @@ fn apply_offsets_to_datetime(
_ => Ok(Int64Chunked::full_null(datetime.0.name(), offsets.len())),
},
(_, 1) => match offsets.get(0) {
Some(offset) => datetime.0.try_apply_nonnull_values_generic(|v| {
offset_fn(&Duration::parse(offset), v, time_zone)
}),
Some(offset) => {
let offset = &Duration::parse(offset);
datetime
.0
.try_apply_nonnull_values_generic(|v| offset_fn(offset, v, time_zone))
},
_ => Ok(datetime.0.apply(|_| None)),
},
_ => try_binary_elementwise(datetime, offsets, |timestamp_opt, offset_opt| {
Expand Down

0 comments on commit 87b84c9

Please sign in to comment.