Skip to content

Commit

Permalink
g This is a combination of 2 commits.
Browse files Browse the repository at this point in the history
fix comm

fix ci
  • Loading branch information
xxhZs committed Dec 30, 2024
1 parent 1571e8f commit a3cb6da
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion e2e_test/batch/types/timestamp_ns.slt.part
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ select v1, v2, coalesce(v2, '1900-01-01 00:00:00') as coalesce_v2 from t1;
query T
select count(v2) as total_rows from t1;
----
4
5

query T rowsort
select * from t1 order by v2;
Expand Down
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 a3cb6da

Please sign in to comment.