I try to translate a legacy query into a standard SQL query in bigquery, but I don't find the function position()
in standard SQL.
Asked
Active
Viewed 760 times
1
1 Answers
1
You may be looking for the bracket operator. For example,
SELECT array_column[OFFSET(0)]
FROM dataset.table
This selects the first element of an array column for each row. If you want to flatten an array and get the offset of each element, you can do so like this:
SELECT x, x_offset
FROM dataset.table,
UNNEST(array_column) AS x WITH OFFSET x_offset
See also the working with arrays documentation.

Elliott Brossard
- 32,095
- 2
- 67
- 99