splitting values of a row into column in BQ but other column values should repeated

Viewed 41

I have a table like below -

Project Col-A Col-B Col-C
A a,b,c,d e,f g
B d,e a,b,c f

& output I want as -

Project Col-A Col-B Col-C
A a e g
A b f null
A c null null
A d null null
B d a f
B e b null
B null c null

I used split function, though the output seems same, but project name isn't repeated for every row (it's blank) & for other columns also it's coming blank instead of null. that's why I can't download the result. it gives me error - "Schema is not flat - cannot save to selected destination."

So for a specific project , maximum number of values present in any of the column will be the max row number in the output. Please help me with the query.

0 Answers
Related