BigQuery 脚本:运行 SQL 查询基于 table 列中包含的每一行

BigQuery scripting: running a SQL query based on each row included in a table column

我的来源table包括url_idSQL[标准sql, 字符串]

我想 运行 字符串列“SQL”中的每个 SQL 语句,并将结果与​​对应的 url_id

预期结果

更新

为了便于重现,我从 public BQ:

导入了一个类似的模式

bigquery-public-data.covid19_italy.data_by_province

如果我运行

select string_agg(
    format('select %i as url_id, (%s) as simpleSKU', url_id, sql), 
    ' union all '   )

FROM `xxx.staging.test_query

它returns

考虑以下

execute immediate (
  select 'select url_id, region_name from (' || string_agg(
    format('select %i as url_id, array(%s) as region_names', url_id, sql), 
    ' union all '
  ) || '), unnest(region_names) as region_name'
  from your_table
);   

如果应用于您问题中的示例数据 - 输出它