@@ -3,27 +3,15 @@ use std::sync::Arc;
33
44use arrow:: datatypes:: DataType ;
55use datafusion_common:: { Result as DataFusionResult , ScalarValue } ;
6- use datafusion_expr:: { ColumnarValue , ScalarFunctionArgs , ScalarUDFImpl , Signature , Volatility } ;
6+ use datafusion_expr:: {
7+ ColumnarValue , ScalarFunctionArgs , ScalarUDFImpl , Signature , TypeSignature , Volatility ,
8+ } ;
79
810use crate :: spin:: spin;
911
1012/// UDF that spins.
1113#[ derive( Debug , PartialEq , Eq , Hash ) ]
12- struct SpinUdf {
13- /// Signature of the UDF.
14- ///
15- /// We store this here because [`ScalarUDFImpl::signature`] requires us to return a reference.
16- signature : Signature ,
17- }
18-
19- impl SpinUdf {
20- /// Create new UDF.
21- fn new ( ) -> Self {
22- Self {
23- signature : Signature :: uniform ( 0 , vec ! [ ] , Volatility :: Immutable ) ,
24- }
25- }
26- }
14+ struct SpinUdf ;
2715
2816impl ScalarUDFImpl for SpinUdf {
2917 fn as_any ( & self ) -> & dyn std:: any:: Any {
@@ -35,7 +23,12 @@ impl ScalarUDFImpl for SpinUdf {
3523 }
3624
3725 fn signature ( & self ) -> & Signature {
38- & self . signature
26+ static S : Signature = Signature {
27+ type_signature : TypeSignature :: Uniform ( 0 , vec ! [ ] ) ,
28+ volatility : Volatility :: Immutable ,
29+ } ;
30+
31+ & S
3932 }
4033
4134 fn return_type ( & self , _arg_types : & [ DataType ] ) -> DataFusionResult < DataType > {
@@ -53,5 +46,5 @@ impl ScalarUDFImpl for SpinUdf {
5346/// The passed `source` is ignored.
5447#[ expect( clippy:: unnecessary_wraps, reason = "public API through export! macro" ) ]
5548pub ( crate ) fn udfs ( _source : String ) -> DataFusionResult < Vec < Arc < dyn ScalarUDFImpl > > > {
56- Ok ( vec ! [ Arc :: new( SpinUdf :: new ( ) ) ] )
49+ Ok ( vec ! [ Arc :: new( SpinUdf ) ] )
5750}
0 commit comments