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

Function array_replace_n_inner

datafusion/functions-nested/src/replace.rs:434–453  ·  view source on GitHub ↗
(args: &[ArrayRef])

Source from the content-addressed store, hash-verified

432}
433
434fn array_replace_n_inner(args: &[ArrayRef]) -> Result<ArrayRef> {
435 let [array, from, to, max] = take_function_args("array_replace_n", args)?;
436
437 // replace the specified number of occurrences
438 let arr_n = as_int64_array(max)?.values().to_vec();
439 match array.data_type() {
440 DataType::List(_) => {
441 let list_array = array.as_list::<i32>();
442 general_replace::<i32>(list_array, from, to, &arr_n)
443 }
444 DataType::LargeList(_) => {
445 let list_array = array.as_list::<i64>();
446 general_replace::<i64>(list_array, from, to, &arr_n)
447 }
448 DataType::Null => Ok(new_null_array(array.data_type(), 1)),
449 array_type => {
450 exec_err!("array_replace_n does not support type '{array_type}'.")
451 }
452 }
453}
454
455fn array_replace_all_inner(args: &[ArrayRef]) -> Result<ArrayRef> {
456 let [array, from, to] = take_function_args("array_replace_all", args)?;

Callers

nothing calls this directly

Calls 5

take_function_argsFunction · 0.85
as_int64_arrayFunction · 0.85
to_vecMethod · 0.80
valuesMethod · 0.45
data_typeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…