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

Function array_replace_inner

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

Source from the content-addressed store, hash-verified

413}
414
415fn array_replace_inner(args: &[ArrayRef]) -> Result<ArrayRef> {
416 let [array, from, to] = take_function_args("array_replace", args)?;
417
418 // replace at most one occurrence for each element
419 let arr_n = vec![1; array.len()];
420 match array.data_type() {
421 DataType::List(_) => {
422 let list_array = array.as_list::<i32>();
423 general_replace::<i32>(list_array, from, to, &arr_n)
424 }
425 DataType::LargeList(_) => {
426 let list_array = array.as_list::<i64>();
427 general_replace::<i64>(list_array, from, to, &arr_n)
428 }
429 DataType::Null => Ok(new_null_array(array.data_type(), 1)),
430 array_type => exec_err!("array_replace does not support type '{array_type}'."),
431 }
432}
433
434fn array_replace_n_inner(args: &[ArrayRef]) -> Result<ArrayRef> {
435 let [array, from, to, max] = take_function_args("array_replace_n", args)?;

Callers

nothing calls this directly

Calls 2

take_function_argsFunction · 0.85
data_typeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…