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

Function array_element_inner

datafusion/functions-nested/src/extract.rs:192–211  ·  view source on GitHub ↗

array_element SQL function There are two arguments for array_element, the first one is the array, the second one is the 1-indexed index. `array_element(array, index)` For example: > array_element(\[1, 2, 3], 2) -> 2

(args: &[ArrayRef])

Source from the content-addressed store, hash-verified

190/// For example:
191/// > array_element(\[1, 2, 3], 2) -> 2
192fn array_element_inner(args: &[ArrayRef]) -> Result<ArrayRef> {
193 let [array, indexes] = take_function_args("array_element", args)?;
194
195 match &array.data_type() {
196 Null => Ok(Arc::new(NullArray::new(array.len()))),
197 List(_) => {
198 let array = as_list_array(&array)?;
199 let indexes = as_int64_array(&indexes)?;
200 general_array_element::<i32>(array, indexes)
201 }
202 LargeList(_) => {
203 let array = as_large_list_array(&array)?;
204 let indexes = as_int64_array(&indexes)?;
205 general_array_element::<i64>(array, indexes)
206 }
207 arg_type => {
208 exec_err!("array_element does not support type {arg_type}")
209 }
210 }
211}
212
213fn general_array_element<O: OffsetSizeTrait>(
214 array: &GenericListArray<O>,

Callers

nothing calls this directly

Calls 7

take_function_argsFunction · 0.85
newFunction · 0.85
as_list_arrayFunction · 0.85
as_int64_arrayFunction · 0.85
as_large_list_arrayFunction · 0.85
data_typeMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…