@@ -113,8 +113,7 @@ pub enum TypeSignature {
113113 /// arguments like `vec![DataType::Int32]` or `vec![DataType::Float32]`
114114 /// since i32 and f32 can be casted to f64
115115 Coercible ( Vec < LogicalTypeRef > ) ,
116- /// Fixed number of arguments of arbitrary types
117- /// If a function takes 0 argument, its `TypeSignature` should be `Any(0)`
116+ /// Fixed number of arguments of arbitrary types, number should be larger than 0
118117 Any ( usize ) ,
119118 /// Matches exactly one of a list of [`TypeSignature`]s. Coercion is attempted to match
120119 /// the signatures in order, and stops after the first success, if any.
@@ -135,6 +134,8 @@ pub enum TypeSignature {
135134 /// Null is considerd as `Utf8` by default
136135 /// Dictionary with string value type is also handled.
137136 String ( usize ) ,
137+ /// Zero argument
138+ NullAry ,
138139}
139140
140141#[ derive( Debug , Clone , PartialEq , Eq , PartialOrd , Hash ) ]
@@ -191,6 +192,9 @@ impl std::fmt::Display for ArrayFunctionSignature {
191192impl TypeSignature {
192193 pub fn to_string_repr ( & self ) -> Vec < String > {
193194 match self {
195+ TypeSignature :: NullAry => {
196+ vec ! [ "NullAry()" . to_string( ) ]
197+ }
194198 TypeSignature :: Variadic ( types) => {
195199 vec ! [ format!( "{}, .." , Self :: join_types( types, "/" ) ) ]
196200 }
@@ -244,7 +248,7 @@ impl TypeSignature {
244248 pub fn supports_zero_argument ( & self ) -> bool {
245249 match & self {
246250 TypeSignature :: Exact ( vec) => vec. is_empty ( ) ,
247- TypeSignature :: Uniform ( 0 , _ ) | TypeSignature :: Any ( 0 ) => true ,
251+ TypeSignature :: NullAry => true ,
248252 TypeSignature :: OneOf ( types) => types
249253 . iter ( )
250254 . any ( |type_sig| type_sig. supports_zero_argument ( ) ) ,
@@ -287,6 +291,7 @@ impl TypeSignature {
287291 . collect ( ) ,
288292 // TODO: Implement for other types
289293 TypeSignature :: Any ( _)
294+ | TypeSignature :: NullAry
290295 | TypeSignature :: VariadicAny
291296 | TypeSignature :: ArraySignature ( _)
292297 | TypeSignature :: UserDefined => vec ! [ ] ,
@@ -407,6 +412,13 @@ impl Signature {
407412 }
408413 }
409414
415+ pub fn nullary ( volatility : Volatility ) -> Self {
416+ Signature {
417+ type_signature : TypeSignature :: NullAry ,
418+ volatility,
419+ }
420+ }
421+
410422 /// A specified number of arguments of any type
411423 pub fn any ( arg_count : usize , volatility : Volatility ) -> Self {
412424 Signature {
@@ -477,13 +489,12 @@ mod tests {
477489 // Testing `TypeSignature`s which supports 0 arg
478490 let positive_cases = vec ! [
479491 TypeSignature :: Exact ( vec![ ] ) ,
480- TypeSignature :: Uniform ( 0 , vec![ DataType :: Float64 ] ) ,
481- TypeSignature :: Any ( 0 ) ,
482492 TypeSignature :: OneOf ( vec![
483493 TypeSignature :: Exact ( vec![ DataType :: Int8 ] ) ,
484- TypeSignature :: Any ( 0 ) ,
494+ TypeSignature :: NullAry ,
485495 TypeSignature :: Uniform ( 1 , vec![ DataType :: Int8 ] ) ,
486496 ] ) ,
497+ TypeSignature :: NullAry ,
487498 ] ;
488499
489500 for case in positive_cases {
0 commit comments