From 825e71412cd081d6eb0e3d8a977059d70118315f Mon Sep 17 00:00:00 2001 From: jayzhan211 Date: Tue, 12 Nov 2024 10:25:25 +0800 Subject: [PATCH] rename to nullary Signed-off-by: jayzhan211 --- datafusion/expr-common/src/signature.rs | 14 +++++++------- datafusion/expr/src/type_coercion/functions.rs | 4 ++-- datafusion/functions-aggregate/src/count.rs | 2 +- datafusion/functions-nested/src/make_array.rs | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/datafusion/expr-common/src/signature.rs b/datafusion/expr-common/src/signature.rs index ddd361adcb29..bbc5765120b5 100644 --- a/datafusion/expr-common/src/signature.rs +++ b/datafusion/expr-common/src/signature.rs @@ -135,7 +135,7 @@ pub enum TypeSignature { /// Dictionary with string value type is also handled. String(usize), /// Zero argument - ZeroArg, + NullAry, } #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Hash)] @@ -192,7 +192,7 @@ impl std::fmt::Display for ArrayFunctionSignature { impl TypeSignature { pub fn to_string_repr(&self) -> Vec { match self { - TypeSignature::ZeroArg => { + TypeSignature::NullAry => { vec!["ZeroArg()".to_string()] } TypeSignature::Variadic(types) => { @@ -248,7 +248,7 @@ impl TypeSignature { pub fn supports_zero_argument(&self) -> bool { match &self { TypeSignature::Exact(vec) => vec.is_empty(), - TypeSignature::ZeroArg => true, + TypeSignature::NullAry => true, TypeSignature::OneOf(types) => types .iter() .any(|type_sig| type_sig.supports_zero_argument()), @@ -291,7 +291,7 @@ impl TypeSignature { .collect(), // TODO: Implement for other types TypeSignature::Any(_) - | TypeSignature::ZeroArg + | TypeSignature::NullAry | TypeSignature::VariadicAny | TypeSignature::ArraySignature(_) | TypeSignature::UserDefined => vec![], @@ -414,7 +414,7 @@ impl Signature { pub fn zero_arg(volatility: Volatility) -> Self { Signature { - type_signature: TypeSignature::ZeroArg, + type_signature: TypeSignature::NullAry, volatility, } } @@ -491,10 +491,10 @@ mod tests { TypeSignature::Exact(vec![]), TypeSignature::OneOf(vec![ TypeSignature::Exact(vec![DataType::Int8]), - TypeSignature::ZeroArg, + TypeSignature::NullAry, TypeSignature::Uniform(1, vec![DataType::Int8]), ]), - TypeSignature::ZeroArg, + TypeSignature::NullAry, ]; for case in positive_cases { diff --git a/datafusion/expr/src/type_coercion/functions.rs b/datafusion/expr/src/type_coercion/functions.rs index 997089cdbb41..6836713d8016 100644 --- a/datafusion/expr/src/type_coercion/functions.rs +++ b/datafusion/expr/src/type_coercion/functions.rs @@ -181,7 +181,7 @@ fn is_well_supported_signature(type_signature: &TypeSignature) -> bool { | TypeSignature::String(_) | TypeSignature::Coercible(_) | TypeSignature::Any(_) - | TypeSignature::ZeroArg + | TypeSignature::NullAry ) } @@ -618,7 +618,7 @@ fn get_valid_types( } } }, - TypeSignature::ZeroArg => { + TypeSignature::NullAry => { if !current_types.is_empty() { return plan_err!( "The function expected zero argument but received {}", diff --git a/datafusion/functions-aggregate/src/count.rs b/datafusion/functions-aggregate/src/count.rs index 2001746177de..52181372698f 100644 --- a/datafusion/functions-aggregate/src/count.rs +++ b/datafusion/functions-aggregate/src/count.rs @@ -102,7 +102,7 @@ impl Count { pub fn new() -> Self { Self { signature: Signature::one_of( - vec![TypeSignature::VariadicAny, TypeSignature::ZeroArg], + vec![TypeSignature::VariadicAny, TypeSignature::NullAry], Volatility::Immutable, ), } diff --git a/datafusion/functions-nested/src/make_array.rs b/datafusion/functions-nested/src/make_array.rs index b6d23b6fd988..de67b0ae3874 100644 --- a/datafusion/functions-nested/src/make_array.rs +++ b/datafusion/functions-nested/src/make_array.rs @@ -63,7 +63,7 @@ impl MakeArray { pub fn new() -> Self { Self { signature: Signature::one_of( - vec![TypeSignature::ZeroArg, TypeSignature::UserDefined], + vec![TypeSignature::NullAry, TypeSignature::UserDefined], Volatility::Immutable, ), aliases: vec![String::from("make_list")],