google-big-queryHow do I use the UNNEST function in Google BigQuery?
The UNNEST function in Google BigQuery is used to expand an array into a set of rows. It can be used to expand multiple arrays at once.
For example, the following query uses the UNNEST function to expand two arrays, arr1
and arr2
, into two sets of rows:
SELECT *
FROM UNNEST(arr1, arr2)
The output from this query would look like this:
Row arr1 arr2
1 1 a
2 2 b
3 3 c
Code explanation
SELECT *
- Selects all columns from the table.FROM UNNEST(arr1, arr2)
- Uses the UNNEST function to expand the two arrays,arr1
andarr2
, into two sets of rows.arr1
andarr2
- The two arrays to be expanded.
Helpful links
More of Google Big Query
- How do I start using Google Big Query?
- How can I use the CASE WHEN statement in Google Big Query?
- How can I use Google Big Query to integrate with Zephyr?
- How do I use the UNION clause in Google BigQuery?
- How do I use Google Big Query with Zoom?
- What are the advantages and disadvantages of using Google BigQuery?
- How can I use Google Big Query to query JSON data?
- How do I use the YEAR function in Google BigQuery?
- How do I query Google BigQuery using XML?
- How can I use Google BigQuery to wait for a query to complete?
See more codes...