ELEMENT_AT

Because the values in arrays are indexed, structured values (not strings as they can appear in a tabular format) you can find the values at different positions in the array. If you want to count from the beginning of the array, you use a positive integer If you want to count from the end of the array, use a negative integer.

ParameterType
array
array
index
integer
Returns: any

Example

Arrays are currently only supported on tables from a live connection to an Athena database. You cannot use them with other databases or with tables derived from an Athena database.

query:

SELECT country_id,
       ELEMENT_AT(cities, 1)
  FROM city_array

query:

SELECT country_id,
       cities[1]
  FROM city_array

results:

country_id element_at
UK London
SG Singapore
US Southlake
CN Beijing
CH Geneva

query:

SELECT country_id,
       ELEMENT_AT(cities, -1)
  FROM city_array

results:

country_id element_at
UK Stretford
SG Singapore
US Seattle
CN Beijing
CH Bern