Skip to content
Advertisement

BigQuery correlated subqueries – transform array to array

I’m trying to join array elements in BigQuery but I am getting the following error message:

Correlated subqueries that reference other tables are not supported unless they can be de-correlated, such as by transforming them into an efficient JOIN.

In my first table I have something like:

field1 | field2 | some_list

Elements in some_list have ids and other data and I’d like to enrich each element from some_list with some fields from a different table (they may exist or not).
I’ve tried to unnest some_list and left join with a different table on id but it seems it’s not allowed.

Any ideas how I can do it? Thanks!

First table:

Second table:

Expected result:

Advertisement

Answer

Consider below generic solution

if applied to sample data in your question – output is

enter image description here

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