Skip to content
Advertisement

Big Query – Transpose array/json objects into columns

This question is a continuation of these two:

  1. Big Query – Transpose arrays into colums
  2. Big Query – Transpose Specific fields into Columns

We have a table in Big Query like below.

Input table:

Note: All the values in the Answer column are stringified values and the Arrays / JSON objects are dynamic.

We want to convert the above table to the below format to make it BI/Visualisation friendly.

Desired table:

Advertisement

Answer

Below is for BigQuery Standard SQL

if to apply to sample data from your question

the output is

enter image description here

Note: EXECUTE IMMEDIATE part of above script is exactly the same as in previous post – the change is only in preparing original data into temp table data and than using it in EXECUTE IMMEDIATE

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement