Skip to content
Advertisement

How to change arrays into rows

There is a table in BigQuery that contains 2 REPEATED(arrays) type of columns, enterded_date and status.

Table in BigQuery:

Table1

Is it possible to make a query that returns rows instead?

Like this:

Table2

Advertisement

Answer

Consider below approach

select t.* except(entered_date, status),
  entered_date, status
from your_table t, 
t.entered_date as entered_date with offset
join t.status as status with offset
using(offset)    

if applied to sample data in your question – output is

enter image description here

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