Skip to content

Commit

Permalink
fix comm
Browse files Browse the repository at this point in the history
  • Loading branch information
xxhZs committed Dec 30, 2024
1 parent 1571e8f commit 2a866bb
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/expr/impl/src/scalar/extract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,18 @@ fn extract_from_datelike(date: impl Datelike, unit: Unit) -> Decimal {

/// Extract field from `Timelike`.
fn extract_from_timelike(time: impl Timelike, unit: Unit) -> Decimal {
let usecs = || time.second() as u64 * 1_000_000_000 + time.nanosecond() as u64;
let nanos = || time.second() as u64 * 1_000_000_000 + time.nanosecond() as u64;
match unit {
Hour => time.hour().into(),
Minute => time.minute().into(),
Second => Decimal::from_i128_with_scale(usecs() as i128, 9),
Millisecond => Decimal::from_i128_with_scale(usecs() as i128, 6),
Microsecond => Decimal::from_i128_with_scale(usecs() as i128, 3),
Nanosecond => usecs().into(),
Second => Decimal::from_i128_with_scale(nanos() as i128, 9),
Millisecond => Decimal::from_i128_with_scale(nanos() as i128, 6),
Microsecond => Decimal::from_i128_with_scale(nanos() as i128, 3),
Nanosecond => nanos().into(),
Epoch => {
let usecs =
let nanos =
time.num_seconds_from_midnight() as u64 * 1_000_000_000 + time.nanosecond() as u64;
Decimal::from_i128_with_scale(usecs as i128, 9)
Decimal::from_i128_with_scale(nanos as i128, 9)
}
u => unreachable!("invalid unit {:?} for time", u),
}
Expand Down

0 comments on commit 2a866bb

Please sign in to comment.