MCPcopy Create free account
hub / github.com/apache/datafusion / take_function_args

Function take_function_args

datafusion/common/src/utils/mod.rs:1053–1067  ·  view source on GitHub ↗

Converts a collection of function arguments into a fixed-size array of length N producing a reasonable error message in case of unexpected number of arguments. # Example ``` # use datafusion_common::Result; # use datafusion_common::utils::take_function_args; # use datafusion_common::ScalarValue; fn my_function(args: &[ScalarValue]) -> Result<()> { // function expects 2 args, so create a 2-element

(
    function_name: &str,
    args: impl IntoIterator<Item = T>,
)

Source from the content-addressed store, hash-verified

1051/// my_function(&args).unwrap();
1052/// ```
1053pub fn take_function_args<const N: usize, T>(
1054 function_name: &str,
1055 args: impl IntoIterator<Item = T>,
1056) -> Result<[T; N]> {
1057 let args = args.into_iter().collect::<Vec<_>>();
1058 args.try_into().map_err(|v: Vec<T>| {
1059 _exec_datafusion_err!(
1060 "{} function requires {} {}, got {}",
1061 function_name,
1062 N,
1063 if N == 1 { "argument" } else { "arguments" },
1064 v.len()
1065 )
1066 })
1067}
1068
1069/// Returns the inner values of a list, or an error otherwise
1070/// For [`ListArray`] and [`LargeListArray`], if it's sliced, it returns a

Callers 15

coerce_typesMethod · 0.85
array_replace_innerFunction · 0.85
array_replace_n_innerFunction · 0.85
array_replace_all_innerFunction · 0.85
array_positions_innerFunction · 0.85
array_dims_innerFunction · 0.85
array_ndims_innerFunction · 0.85
coerce_typesMethod · 0.85
cosine_distance_innerFunction · 0.85
lambda_parametersMethod · 0.85

Calls 1

into_iterMethod · 0.45

Tested by 2

coerce_typesMethod · 0.68
invoke_with_argsMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…