@@ -2786,8 +2786,16 @@ fn register_timestamp_from_parts(registry: &mut FunctionRegistry) {
27862786 Vec < DataType > ,
27872787 fn ( & [ Value < AnyType > ] , & mut EvalContext ) -> Value < AnyType > ,
27882788 ) = match args_type. len ( ) {
2789- 6 => ( vec ! [ int64_type; 6 ] , timestamp_from_parts_6 as _ ) ,
2790- 7 => ( vec ! [ int64_type; 7 ] , timestamp_from_parts_7 as _ ) ,
2789+ // 6 args: year, month, day, hour, minute, second
2790+ 6 => ( vec ! [ int64_type; 6 ] , |args, ctx| {
2791+ timestamp_from_parts_fn ( args, ctx, false )
2792+ } ) ,
2793+
2794+ // 7 args: includes nanosecond
2795+ 7 => ( vec ! [ int64_type; 7 ] , |args, ctx| {
2796+ timestamp_from_parts_fn ( args, ctx, true )
2797+ } ) ,
2798+
27912799 _ => return None ,
27922800 } ;
27932801
@@ -2809,14 +2817,6 @@ fn register_timestamp_from_parts(registry: &mut FunctionRegistry) {
28092817 registry. register_function_factory ( "timestamp_from_parts" , factory) ;
28102818}
28112819
2812- fn timestamp_from_parts_6 ( args : & [ Value < AnyType > ] , ctx : & mut EvalContext ) -> Value < AnyType > {
2813- timestamp_from_parts_fn ( args, ctx, false )
2814- }
2815-
2816- fn timestamp_from_parts_7 ( args : & [ Value < AnyType > ] , ctx : & mut EvalContext ) -> Value < AnyType > {
2817- timestamp_from_parts_fn ( args, ctx, true )
2818- }
2819-
28202820fn register_timestamp_tz_from_parts ( registry : & mut FunctionRegistry ) {
28212821 registry. register_aliases ( "timestamp_tz_from_parts" , & [ "timestamptzfromparts" ] ) ;
28222822
@@ -2828,20 +2828,36 @@ fn register_timestamp_tz_from_parts(registry: &mut FunctionRegistry) {
28282828 Vec < DataType > ,
28292829 fn ( & [ Value < AnyType > ] , & mut EvalContext ) -> Value < AnyType > ,
28302830 ) = match args_type. len ( ) {
2831- 6 => ( vec ! [ int64_type; 6 ] , timestamp_tz_from_parts_6 as _ ) ,
2831+ // 6 args: no nanoseconds, no timezone
2832+ 6 => ( vec ! [ int64_type; 6 ] , |args, ctx| {
2833+ timestamp_tz_from_parts_fn ( args, ctx, false , false )
2834+ } ) ,
28322835
2836+ // 7 args: timezone provided
28332837 7 if args_type[ 6 ] . remove_nullable ( ) == DataType :: String => {
28342838 let mut v = vec ! [ int64_type; 6 ] ;
28352839 v. push ( DataType :: String ) ;
2836- ( v, timestamp_tz_from_parts_7_tz as _ )
2840+
2841+ // year, month, day, hour, minute, second, timezone
2842+ ( v, |args, ctx| {
2843+ timestamp_tz_from_parts_fn ( args, ctx, false , true )
2844+ } )
28372845 }
28382846
2839- 7 => ( vec ! [ int64_type; 7 ] , timestamp_tz_from_parts_7_nano as _ ) ,
2847+ // 7 args: nanoseconds
2848+ 7 => ( vec ! [ int64_type; 7 ] , |args, ctx| {
2849+ timestamp_tz_from_parts_fn ( args, ctx, true , false )
2850+ } ) ,
28402851
2852+ // 8 args: nanoseconds + timezone
28412853 8 => {
28422854 let mut v = vec ! [ int64_type; 7 ] ;
28432855 v. push ( DataType :: String ) ;
2844- ( v, timestamp_tz_from_parts_8 as _ )
2856+
2857+ // year, month, day, hour, minute, second, nanosecond, timezone
2858+ ( v, |args, ctx| {
2859+ timestamp_tz_from_parts_fn ( args, ctx, true , true )
2860+ } )
28452861 }
28462862
28472863 _ => return None ,
@@ -2865,25 +2881,6 @@ fn register_timestamp_tz_from_parts(registry: &mut FunctionRegistry) {
28652881 registry. register_function_factory ( "timestamp_tz_from_parts" , factory) ;
28662882}
28672883
2868- fn timestamp_tz_from_parts_6 ( args : & [ Value < AnyType > ] , ctx : & mut EvalContext ) -> Value < AnyType > {
2869- timestamp_tz_from_parts_fn ( args, ctx, false , false )
2870- }
2871-
2872- fn timestamp_tz_from_parts_7_nano (
2873- args : & [ Value < AnyType > ] ,
2874- ctx : & mut EvalContext ,
2875- ) -> Value < AnyType > {
2876- timestamp_tz_from_parts_fn ( args, ctx, true , false )
2877- }
2878-
2879- fn timestamp_tz_from_parts_7_tz ( args : & [ Value < AnyType > ] , ctx : & mut EvalContext ) -> Value < AnyType > {
2880- timestamp_tz_from_parts_fn ( args, ctx, false , true )
2881- }
2882-
2883- fn timestamp_tz_from_parts_8 ( args : & [ Value < AnyType > ] , ctx : & mut EvalContext ) -> Value < AnyType > {
2884- timestamp_tz_from_parts_fn ( args, ctx, true , true )
2885- }
2886-
28872884fn build_timestamp_parts (
28882885 args : & [ Value < AnyType > ] ,
28892886 ctx : & mut EvalContext ,
0 commit comments