From 8483b76739abe5daf277ecfa5d1b7ed942de33aa Mon Sep 17 00:00:00 2001 From: jayzhan211 Date: Mon, 4 Dec 2023 09:18:20 +0800 Subject: [PATCH] improve comment Signed-off-by: jayzhan211 --- datafusion/common/src/utils.rs | 24 +++++++++++++----------- datafusion/expr/src/signature.rs | 6 ++++-- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/datafusion/common/src/utils.rs b/datafusion/common/src/utils.rs index b97ec868edd47..a10428a7224ef 100644 --- a/datafusion/common/src/utils.rs +++ b/datafusion/common/src/utils.rs @@ -427,7 +427,7 @@ pub fn base_type(data_type: &DataType) -> DataType { } } -/// Coerced only the base type. +/// A helper function to coerce base type in List. /// /// Example /// ``` @@ -444,18 +444,20 @@ pub fn coerced_type_with_base_type_only( base_type: &DataType, ) -> DataType { match data_type { - DataType::List(field) => match field.data_type() { - DataType::List(_) => DataType::List(Arc::new(Field::new( - field.name(), - coerced_type_with_base_type_only(field.data_type(), base_type), - field.is_nullable(), - ))), - _ => DataType::List(Arc::new(Field::new( + DataType::List(field) => { + let data_type = match field.data_type() { + DataType::List(_) => { + coerced_type_with_base_type_only(field.data_type(), base_type) + } + _ => base_type.to_owned(), + }; + + DataType::List(Arc::new(Field::new( field.name(), - base_type.clone(), + data_type, field.is_nullable(), - ))), - }, + ))) + } _ => base_type.clone(), } diff --git a/datafusion/expr/src/signature.rs b/datafusion/expr/src/signature.rs index 8c5fff507ea06..2e0e4ca731c44 100644 --- a/datafusion/expr/src/signature.rs +++ b/datafusion/expr/src/signature.rs @@ -140,14 +140,16 @@ impl TypeSignature { .collect::>() .join(", ")] } - TypeSignature::VariadicCoerced => vec!["CoercibleT, .., CoercibleT".to_string()], + TypeSignature::VariadicCoerced => { + vec!["CoercibleT, .., CoercibleT".to_string()] + } TypeSignature::VariadicEqual => vec!["T, .., T".to_string()], TypeSignature::VariadicAny => vec!["Any, .., Any".to_string()], TypeSignature::OneOf(sigs) => { sigs.iter().flat_map(|s| s.to_string_repr()).collect() } TypeSignature::ArrayAppendLikeSignature => { - vec!["ArrayAppendLikeSignature".to_string()] + vec!["ArrayAppendLikeSignature(List, T)".to_string()] } } }