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

Function general_position_dispatch

datafusion/functions-nested/src/position.rs:302–325  ·  view source on GitHub ↗
(args: &[ArrayRef])

Source from the content-addressed store, hash-verified

300}
301
302fn general_position_dispatch<O: OffsetSizeTrait>(args: &[ArrayRef]) -> Result<ArrayRef> {
303 let haystack = as_generic_list_array::<O>(&args[0])?;
304 let needle = &args[1];
305
306 crate::utils::check_datatypes("array_position", &[haystack.values(), needle])?;
307
308 let arr_from = if args.len() == 3 {
309 as_int64_array(&args[2])?
310 .values()
311 .iter()
312 .map(|&x| x - 1)
313 .collect::<Vec<_>>()
314 } else {
315 vec![0; haystack.len()]
316 };
317
318 for (row, &from) in haystack.iter().zip(arr_from.iter()) {
319 if !row.is_none_or(|row| from >= 0 && (from as usize) <= row.len()) {
320 return exec_err!("start_from out of bounds: {}", from + 1);
321 }
322 }
323
324 generic_position::<O>(haystack, needle, &arr_from)
325}
326
327fn generic_position<O: OffsetSizeTrait>(
328 haystack: &GenericListArray<O>,

Callers

nothing calls this directly

Calls 6

check_datatypesFunction · 0.85
as_int64_arrayFunction · 0.85
valuesMethod · 0.45
lenMethod · 0.45
mapMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…