Вы можете использовать ниже запрос:
with data as (
select STRUCT<item ARRAY<STRING>, unit_cost ARRAY<INT64>, quantity ARRAY<INT64>>
(['cheese', 'ham', 'salad'], [2, 5, 8], [1, 2, 1]) entry
union all
select (['othercheese', 'otherham', 'othersalad'], [3, 8, 10], [11, 22, 11])
union all
select (['othercheese', 'otherham', 'othersalad'], [3, 8, 10], [11, 22, 11])
)
SELECT ARRAY_AGG(STRUCT(item, unit_cost, quantity))
FROM data, UNNEST(entry.item) item WITH OFFSET
LEFT JOIN UNNEST(entry.unit_cost) unit_cost WITH OFFSET USING(OFFSET)
LEFT JOIN UNNEST(entry.quantity) quantity WITH OFFSET USING(OFFSET)
Выход
[
{
"f0_": [
{
"item": "cheese",
"unit_cost": "2",
"quantity": "1"
},
{
"item": "ham",
"unit_cost": "5",
"quantity": "2"
},
{
"item": "salad",
"unit_cost": "8",
"quantity": "1"
},
{
"item": "othercheese",
"unit_cost": "3",
"quantity": "11"
},
{
"item": "otherham",
"unit_cost": "8",
"quantity": "22"
},
{
"item": "othersalad",
"unit_cost": "10",
"quantity": "11"
},
{
"item": "othercheese",
"unit_cost": "3",
"quantity": "11"
},
{
"item": "otherham",
"unit_cost": "8",
"quantity": "22"
},
{
"item": "othersalad",
"unit_cost": "10",
"quantity": "11"
}
]
}
]