Skip to content

Commit

Permalink
Revert "Refactors shift offset computation"
Browse files Browse the repository at this point in the history
This reverts commit 000ceb7.
  • Loading branch information
jcsherin committed Oct 11, 2024
1 parent ea811c6 commit 3b6bc5d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions datafusion/functions-window/src/lead_lag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ impl WindowShiftKind {
}
}

fn shift_offset(&self, value: i64) -> i64 {
fn shift_offset(&self, value: Option<i64>) -> i64 {
match self {
WindowShiftKind::Lag => value,
WindowShiftKind::Lead => value.neg(),
WindowShiftKind::Lag => value.unwrap_or(1),
WindowShiftKind::Lead => value.map(|v| v.neg()).unwrap_or(-1),
}
}
}
Expand Down Expand Up @@ -146,11 +146,11 @@ impl WindowUDFImpl for WindowShift {
) -> Result<Box<dyn PartitionEvaluator>> {
let shift_offset = scalar_at(&partition_evaluator_args, 1)?
.map(get_signed_integer)
.unwrap_or(Ok(1))
.map_or(Ok(None), |v| v.map(Some))
.map(|n| self.kind.shift_offset(n))
.map(|offset| {
if partition_evaluator_args.is_reversed() {
offset.neg()
-offset
} else {
offset
}
Expand Down

0 comments on commit 3b6bc5d

Please sign in to comment.