L-square
L-square

Reputation: 125

Split and create an array with Google BigQuery

Starting point:

id  levels
    
11   A,B,C      
12   A
13   B,C

How to split and create an array, expected outcome:

id  levels
    
11   A
11   B
11   C      
12   A
13   B
13   C

Upvotes: 2

Views: 1603

Answers (1)

You can use split:

select id,split(levels,',') as levels yourtable

You can also use UNNEST

SELECT id, levels
FROM yourtable
CROSS JOIN UNNEST(levels) AS levels;

Upvotes: 2

Related Questions