@@ -50,33 +50,29 @@ macro_rules! make_udlf_expr_and_func {
5050 make_udlf_expr_and_func!( $UDF, $EXPR_FN, $( $arg) * , $DOC, $LAMBDA_UDF_FN, $UDF:: new) ;
5151 } ;
5252 ( $UDF: ident, $EXPR_FN: ident, $( $arg: ident) * , $DOC: expr, $LAMBDA_UDF_FN: ident, $CTOR: path) => {
53- paste:: paste! {
54- // "fluent expr_fn" style function
55- #[ doc = $DOC]
56- pub fn $EXPR_FN( $( $arg: datafusion_expr:: Expr ) ,* ) -> datafusion_expr:: Expr {
57- datafusion_expr:: Expr :: LambdaFunction ( datafusion_expr:: expr:: LambdaFunction :: new(
58- $LAMBDA_UDF_FN( ) ,
59- vec![ $( $arg) ,* ] ,
60- ) )
61- }
62- create_lambda!( $UDF, $LAMBDA_UDF_FN, $CTOR) ;
53+ // "fluent expr_fn" style function
54+ #[ doc = $DOC]
55+ pub fn $EXPR_FN( $( $arg: datafusion_expr:: Expr ) ,* ) -> datafusion_expr:: Expr {
56+ datafusion_expr:: Expr :: LambdaFunction ( datafusion_expr:: expr:: LambdaFunction :: new(
57+ $LAMBDA_UDF_FN( ) ,
58+ vec![ $( $arg) ,* ] ,
59+ ) )
6360 }
61+ create_lambda!( $UDF, $LAMBDA_UDF_FN, $CTOR) ;
6462 } ;
6563 ( $UDF: ident, $EXPR_FN: ident, $DOC: expr, $LAMBDA_UDF_FN: ident) => {
6664 make_udlf_expr_and_func!( $UDF, $EXPR_FN, $DOC, $LAMBDA_UDF_FN, $UDF:: new) ;
6765 } ;
6866 ( $UDF: ident, $EXPR_FN: ident, $DOC: expr, $LAMBDA_UDF_FN: ident, $CTOR: path) => {
69- paste:: paste! {
70- // "fluent expr_fn" style function
71- #[ doc = $DOC]
72- pub fn $EXPR_FN( arg: Vec <datafusion_expr:: Expr >) -> datafusion_expr:: Expr {
73- datafusion_expr:: Expr :: LambdaFunction ( datafusion_expr:: expr:: LambdaFunction :: new(
74- $LAMBDA_UDF_FN( ) ,
75- arg,
76- ) )
77- }
78- create_lambda!( $UDF, $LAMBDA_UDF_FN, $CTOR) ;
67+ // "fluent expr_fn" style function
68+ #[ doc = $DOC]
69+ pub fn $EXPR_FN( arg: Vec <datafusion_expr:: Expr >) -> datafusion_expr:: Expr {
70+ datafusion_expr:: Expr :: LambdaFunction ( datafusion_expr:: expr:: LambdaFunction :: new(
71+ $LAMBDA_UDF_FN( ) ,
72+ arg,
73+ ) )
7974 }
75+ create_lambda!( $UDF, $LAMBDA_UDF_FN, $CTOR) ;
8076 } ;
8177}
8278
@@ -97,17 +93,15 @@ macro_rules! create_lambda {
9793 create_lambda!( $UDF, $LAMBDA_UDF_FN, $UDF:: new) ;
9894 } ;
9995 ( $UDF: ident, $LAMBDA_UDF_FN: ident, $CTOR: path) => {
100- paste:: paste! {
101- #[ doc = concat!( "LambdaFunction that returns a [`LambdaUDF`](datafusion_expr::LambdaUDF) for " ) ]
102- #[ doc = stringify!( $UDF) ]
103- pub fn $LAMBDA_UDF_FN( ) -> std:: sync:: Arc <dyn datafusion_expr:: LambdaUDF > {
104- // Singleton instance of [`$UDF`], ensures the UDF is only created once
105- static INSTANCE : std:: sync:: LazyLock <std:: sync:: Arc <dyn datafusion_expr:: LambdaUDF >> =
106- std:: sync:: LazyLock :: new( || {
107- std:: sync:: Arc :: new( $CTOR( ) )
108- } ) ;
109- std:: sync:: Arc :: clone( & INSTANCE )
110- }
96+ #[ doc = concat!( "LambdaFunction that returns a [`LambdaUDF`](datafusion_expr::LambdaUDF) for " ) ]
97+ #[ doc = stringify!( $UDF) ]
98+ pub fn $LAMBDA_UDF_FN( ) -> std:: sync:: Arc <dyn datafusion_expr:: LambdaUDF > {
99+ // Singleton instance of [`$UDF`], ensures the UDF is only created once
100+ static INSTANCE : std:: sync:: LazyLock <std:: sync:: Arc <dyn datafusion_expr:: LambdaUDF >> =
101+ std:: sync:: LazyLock :: new( || {
102+ std:: sync:: Arc :: new( $CTOR( ) )
103+ } ) ;
104+ std:: sync:: Arc :: clone( & INSTANCE )
111105 }
112106 } ;
113107}
0 commit comments