以下是 BigQuery 标准 SQL
#standardSQL
SELECT
b.*,
t.field1,
t.field2
FROM `table1` AS b, UNNEST(Seats) AS Seat
JOIN `table2` AS t
ON b.Row = t.RowLabel
AND Seat = t.SeatLabel
您可以使用如下的虚拟数据对其进行测试
#standardSQL
WITH `table1` AS (
SELECT '1' AS Row, ['a', 'b', 'c'] AS Seats
),
`table2` AS (
SELECT '1' AS RowLabel, 'b' AS SeatLabel, 111 AS field1, 222 AS field2 UNION ALL
SELECT '1' AS RowLabel, 'a' AS SeatLabel, 111 AS field1, 222 AS field2 UNION ALL
SELECT '1' AS RowLabel, 'd' AS SeatLabel, 111 AS field1, 222 AS field2
)
SELECT
b.*,
t.field1,
t.field2
FROM `table1` AS b, UNNEST(Seats) AS Seat
JOIN `table2` AS t
ON b.Row = t.RowLabel
AND Seat = t.SeatLabel