SQL/Presto 将列表列扩展为多行

SQL/Presto expanding a list column into multiple rows

给了一个蜂巢table喜欢

a  |   b
----------
1  |  [1,2,3]
2  |  [2,3]

如何创建辅助 table 喜欢

a | b
------
1 | 1
1 | 2 
1 | 3 
2 | 2 
2 | 3 

这是unnest的教科书案例:

-- sample data
WITH dataset (a, b) AS (
    VALUES (1, array[1,2,3]),
    (2, array[2,3])
) 

-- query
select a, bb
from dataset
cross join unnest(b) as t(bb)
order by a, bb -- to pretify output

输出:

a bb
1 1
1 2
1 3
2 2
2 3