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])
| 190 | /// For example: |
| 191 | /// > array_element(\[1, 2, 3], 2) -> 2 |
| 192 | fn 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 | |
| 213 | fn general_array_element<O: OffsetSizeTrait>( |
| 214 | array: &GenericListArray<O>, |
nothing calls this directly
no test coverage detected
searching dependent graphs…