Arrays in Bigquery

Bhanu chander Shyamala

Data Analyst

Arrays in Bigquery

What is an array?

  • An array is a collection of similar data items.You can construct arrays of simple data types, such as INT64, and complex data types, such as STRUCTs.Array of arrays are not supported in bigquery.
  • You can combine arrays using functions like ARRAY_CONCAT(), and convert arrays to strings using ARRAY_TO_STRING().
  • Basic array created in bigquery as shown below

    To find the length of array in bigquery

    ARR_AGG expression in bigquery

  • As we have used the ARR_AGG function so it is showing 2 records as output other wise it would have retrieved 4 records
  • ARRAY UNION ALL

    ARRAY_CONCAT_AGG

  • BigQuery also supports an aggregate function, ARRAY_CONCAT_AGG(), which concatenates the elements of an array column across rows.
  • Converting arrays to string

  • The ARRAY_TO_STRING() function allows you to convert an ARRAY -STRING- to a single STRING value
  • Comments

    Popular posts from this blog

    Overview of data storage and sql commands