取消嵌套 BQ 的最简单方法 table

Simplest way to unnest a BQ table

我可以直接从 BQ 中的文字中取消嵌套数组,如下所示:

select * from unnest([1,2,3])
# [{"f0_": "1"},{"f0_": "2"},{"f0_": "3"}]

如何从 with 语句中执行相同的操作?例如,类似于:

with Table as (
  select [1,2,3] as arr
 ) select * from unnest(Table.arr) ?? -- currently get unrecognized table name

以上的正确语法是什么?这是我想出的一个例子:这是进行一般 unnest 的最简单方法吗?

with Movie as (
  select "Spider-Man" as Title, ['Sci-Fi', 'Action'] as Genres
 ) select Movie.Title, Genre from Movie cross join unnest(Movie.Genres) Genre

如果是这样,为什么没有交叉连接就不能完成上述操作?

How can I do the same from a with statement?

with Table as (
  select [1,2,3] as arr
) 
select x from Table, unnest(arr) x   

is this the simplest way to do a general unnest?

是的!