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,arr1andarr2, into two sets of rows.arr1andarr2- The two arrays to be expanded.
Helpful links
More of Google Big Query
- How do I use a Google BigQuery URL?
- How can I determine the length of a string in Google BigQuery?
- How do I connect Google Big Query to Tableau?
- How do I use Google Big Query to merge data?
- How do Google BigQuery and Azure Data Lake compare in terms of performance and cost?
- How can I use Google BigQuery to install packages from PyPI?
- How can I use Google BigQuery ML to build a machine learning model?
- How do I use Google Big Query with npm?
- How do I use Google BigQuery LIKE statements?
See more codes...