Skip to content

Commit e44ae0a

Browse files
authored
Saner handling of nulls inside arrays (#15149)
* Saner handling of nulls inside arrays * Fix array_sort for empty record batch * Fix get_valid_types for FixedSizeLists * Optimize array_ndims * Add a test for result type of Concatenating Mixed types * Fix array_element of empty array * Handle more FixedSizeLists
1 parent 2d27ce4 commit e44ae0a

File tree

15 files changed

+715
-551
lines changed

15 files changed

+715
-551
lines changed

datafusion/expr-common/src/signature.rs

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -843,14 +843,16 @@ impl Signature {
843843
volatility,
844844
}
845845
}
846+
846847
/// Any one of a list of [TypeSignature]s.
847848
pub fn one_of(type_signatures: Vec<TypeSignature>, volatility: Volatility) -> Self {
848849
Signature {
849850
type_signature: TypeSignature::OneOf(type_signatures),
850851
volatility,
851852
}
852853
}
853-
/// Specialized Signature for ArrayAppend and similar functions
854+
855+
/// Specialized [Signature] for ArrayAppend and similar functions.
854856
pub fn array_and_element(volatility: Volatility) -> Self {
855857
Signature {
856858
type_signature: TypeSignature::ArraySignature(
@@ -865,7 +867,41 @@ impl Signature {
865867
volatility,
866868
}
867869
}
868-
/// Specialized Signature for Array functions with an optional index
870+
871+
/// Specialized [Signature] for ArrayPrepend and similar functions.
872+
pub fn element_and_array(volatility: Volatility) -> Self {
873+
Signature {
874+
type_signature: TypeSignature::ArraySignature(
875+
ArrayFunctionSignature::Array {
876+
arguments: vec![
877+
ArrayFunctionArgument::Element,
878+
ArrayFunctionArgument::Array,
879+
],
880+
array_coercion: Some(ListCoercion::FixedSizedListToList),
881+
},
882+
),
883+
volatility,
884+
}
885+
}
886+
887+
/// Specialized [Signature] for functions that take a fixed number of arrays.
888+
pub fn arrays(
889+
n: usize,
890+
coercion: Option<ListCoercion>,
891+
volatility: Volatility,
892+
) -> Self {
893+
Signature {
894+
type_signature: TypeSignature::ArraySignature(
895+
ArrayFunctionSignature::Array {
896+
arguments: vec![ArrayFunctionArgument::Array; n],
897+
array_coercion: coercion,
898+
},
899+
),
900+
volatility,
901+
}
902+
}
903+
904+
/// Specialized [Signature] for Array functions with an optional index.
869905
pub fn array_and_element_and_optional_index(volatility: Volatility) -> Self {
870906
Signature {
871907
type_signature: TypeSignature::OneOf(vec![
@@ -889,7 +925,7 @@ impl Signature {
889925
}
890926
}
891927

892-
/// Specialized Signature for ArrayElement and similar functions
928+
/// Specialized [Signature] for ArrayElement and similar functions.
893929
pub fn array_and_index(volatility: Volatility) -> Self {
894930
Signature {
895931
type_signature: TypeSignature::ArraySignature(
@@ -898,23 +934,16 @@ impl Signature {
898934
ArrayFunctionArgument::Array,
899935
ArrayFunctionArgument::Index,
900936
],
901-
array_coercion: None,
937+
array_coercion: Some(ListCoercion::FixedSizedListToList),
902938
},
903939
),
904940
volatility,
905941
}
906942
}
907-
/// Specialized Signature for ArrayEmpty and similar functions
943+
944+
/// Specialized [Signature] for ArrayEmpty and similar functions.
908945
pub fn array(volatility: Volatility) -> Self {
909-
Signature {
910-
type_signature: TypeSignature::ArraySignature(
911-
ArrayFunctionSignature::Array {
912-
arguments: vec![ArrayFunctionArgument::Array],
913-
array_coercion: None,
914-
},
915-
),
916-
volatility,
917-
}
946+
Signature::arrays(1, Some(ListCoercion::FixedSizedListToList), volatility)
918947
}
919948
}
920949

0 commit comments

Comments
 (0)