I am currently working with a very simple table on BigQuery and each row has two repeated columns class_numbers
[REPEATED INTEGER]
and class_
Using standard SQL, you can use UNNEST(...) WITH OFFSET
. For example,
SELECT
class_number,
class_descriptions[OFFSET(off)] AS class_description
FROM MyTable,
UNNEST(class_numbers) AS class_number WITH OFFSET off;
Below is version for BigQuery Legacy SQL
SELECT
class_number,
class_description
FROM (
SELECT
class_number,
number_pos,
class_descriptions AS class_description,
POSITION(class_descriptions) AS description_pos
FROM FLATTEN((
SELECT
class_numbers AS class_number,
POSITION(class_numbers) AS number_pos,
class_descriptions
FROM YourTable
), class_numbers)
)
WHERE number_pos = description_pos