@@ -61,8 +61,6 @@ use databend_common_expression::types::StringType;
6161use databend_common_expression:: types:: TimestampType ;
6262use databend_common_expression:: types:: F64 ;
6363use databend_common_expression:: utils:: date_helper:: * ;
64- use databend_common_timezone:: fast_components_from_timestamp;
65- use databend_common_timezone:: fast_utc_from_local;
6664use databend_common_expression:: vectorize_1_arg;
6765use databend_common_expression:: vectorize_2_arg;
6866use databend_common_expression:: vectorize_4_arg;
@@ -75,6 +73,8 @@ use databend_common_expression::FunctionDomain;
7573use databend_common_expression:: FunctionProperty ;
7674use databend_common_expression:: FunctionRegistry ;
7775use databend_common_expression:: Value ;
76+ use databend_common_timezone:: fast_components_from_timestamp;
77+ use databend_common_timezone:: fast_utc_from_local;
7878use dtparse:: parse;
7979use jiff:: civil:: date;
8080use jiff:: civil:: Date ;
@@ -613,16 +613,7 @@ fn fast_timestamp_from_tm(tm: &BrokenDownTime, tz: &TimeZone) -> Option<i64> {
613613 let second: u8 = tm. second ( ) . unwrap_or ( 0 ) . try_into ( ) . ok ( ) ?;
614614 let nanos = tm. subsec_nanosecond ( ) . unwrap_or ( 0 ) ;
615615 let micro = ( nanos / 1_000 ) . max ( 0 ) as u32 ;
616- fast_utc_from_local (
617- tz,
618- year,
619- month,
620- day,
621- hour,
622- minute,
623- second,
624- micro,
625- )
616+ fast_utc_from_local ( tz, year, month, day, hour, minute, second, micro)
626617}
627618
628619fn register_date_to_timestamp ( registry : & mut FunctionRegistry ) {
@@ -977,9 +968,8 @@ fn timestamp_days_via_lut(value: i64, tz: &TimeZone) -> Option<i32> {
977968}
978969
979970fn days_from_components ( year : i32 , month : u8 , day : u8 ) -> Option < i32 > {
980- NaiveDate :: from_ymd_opt ( year, month as u32 , day as u32 ) . map ( |d| {
981- clamp_date ( ( d. num_days_from_ce ( ) - EPOCH_DAYS_FROM_CE ) as i64 )
982- } )
971+ NaiveDate :: from_ymd_opt ( year, month as u32 , day as u32 )
972+ . map ( |d| clamp_date ( ( d. num_days_from_ce ( ) - EPOCH_DAYS_FROM_CE ) as i64 ) )
983973}
984974
985975fn timestamp_days_via_jiff ( value : i64 , tz : & TimeZone ) -> i32 {
@@ -993,10 +983,11 @@ fn timestamp_days_via_jiff(value: i64, tz: &TimeZone) -> i32 {
993983
994984#[ cfg( test) ]
995985mod tests {
996- use super :: * ;
997986 use chrono:: NaiveDate ;
998987 use jiff:: tz:: TimeZone ;
999988
989+ use super :: * ;
990+
1000991 fn micros_for_utc ( year : i32 , month : u32 , day : u32 , hour : u32 , minute : u32 , second : u32 ) -> i64 {
1001992 let naive = NaiveDate :: from_ymd_opt ( year, month, day)
1002993 . unwrap ( )
@@ -1025,10 +1016,7 @@ mod tests {
10251016 let tz = TimeZone :: UTC ;
10261017 let past = micros_for_utc ( 1800 , 7 , 1 , 0 , 0 , 0 ) ;
10271018 assert ! ( timestamp_days_via_lut( past, & tz) . is_none( ) ) ;
1028- assert_eq ! (
1029- timestamp_to_date_days( past, & tz) ,
1030- expected_days( 1800 , 7 , 1 )
1031- ) ;
1019+ assert_eq ! ( timestamp_to_date_days( past, & tz) , expected_days( 1800 , 7 , 1 ) ) ;
10321020
10331021 let future = micros_for_utc ( 2400 , 3 , 15 , 12 , 0 , 0 ) ;
10341022 assert ! ( timestamp_days_via_lut( future, & tz) . is_none( ) ) ;
0 commit comments