Skip to content

Commit

Permalink
use val directly
Browse files Browse the repository at this point in the history
  • Loading branch information
TCeason committed Jan 31, 2025
1 parent eb18832 commit fce6e32
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
9 changes: 1 addition & 8 deletions src/query/functions/src/scalars/timestamp/src/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1519,14 +1519,7 @@ fn register_to_number_functions(registry: &mut FunctionRegistry) {
registry.register_passthrough_nullable_1_arg::<TimestampType, Float64Type, _, _>(
"epoch_microsecond",
|_, _| FunctionDomain::Full,
vectorize_1_arg::<TimestampType, Float64Type>(|val, ctx| {
(val.to_timestamp(ctx.func_ctx.tz.clone())
.with_time_zone(TimeZone::UTC)
.timestamp()
.as_microsecond() as f64
/ 1_000_000f64)
.into()
}),
vectorize_1_arg::<TimestampType, Float64Type>(|val, _| (val as f64 / 1_000_000f64).into()),
);

registry.register_passthrough_nullable_1_arg::<TimestampType, UInt8Type, _, _>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1124,6 +1124,16 @@ select EXTRACT(YEAR FROM to_datetime('2022-03-04 22:32:09')) = 2022
----
1

query T
select EXTRACT(EPOCH FROM to_datetime('1969-12-31 23:59:59.999999'))
----
-1

query T
select EXTRACT(EPOCH FROM to_datetime('1969-12-31 23:59:59.999999'))
----
-0.000001

query B
select EXTRACT(EPOCH FROM to_datetime('2022-03-04 22:32:09')) = to_unix_timestamp('2022-03-04 22:32:09');
----
Expand Down

0 comments on commit fce6e32

Please sign in to comment.