ELEMENT_AT
Retrieves the element of an array at a given index.
Syntax
Arguments
ARRAY(E)
ARRAY(E)
Type: array
A array of values of any type.
INDEX
INDEX
Type: integer
An integer indicating the index of the element to retrieve.
If INDEX > 0
, this function provides the same functionality as the SQL-standard subscript operator ([]
).
If INDEX < 0
, this function accesses elements from the last to the first.
Note that if the ARRAY
contains any null
values, they are ignored in the indexing of the array.
Returns
Type: same as input
The element of ARRAY
at the given INDEX
.
Note that if the INDEX
is 0, then the function returns null
.
Examples
ARRAY | INDEX | Output |
---|---|---|
| 1 | 5 |
| 4 | 1 |
| 10 |
|
| -2 | 6 |
| 3 | p |
Transformation job example
SQL
Query result
element_example1 | element_example2 |
---|---|
| 4 |
Last updated