Querying multiple repeated fields in BigQuery

后端 未结 3 923
有刺的猬
有刺的猬 2020-12-28 20:56

I have a schema that contains multiple repeated fields which are not nested.

I\'m trying to query the cross product, but I get an error: \"Cannot query the cross pr

3条回答
  •  梦毁少年i
    2020-12-28 21:44

    Now that BigQuery has moved to Standard SQL, using FLATTEN doesn't work. However Google has documented how to migrate. This solution worked for me, although there are several other ways to do it:

    SELECT
      flattened_field_1,
      flattened_field_2
    
    FROM my_dataset.my_table
    LEFT JOIN UNNEST(repeated_field_1) AS flattened_field_1
    LEFT JOIN UNNEST(repeated_field_2) AS flattened_field_2
    # ...etc
    

提交回复
热议问题