2021年1月25日星期一

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

My origin table includes url_id and SQL [standard sql, string]

enter image description here

I would like to run each of the SQL statements in the string column "SQL" and join the outcome with the correspondent url_id

expected outcome

enter image description here

UPDATE

to make this easy to reproduce I´ve imported a similar schema from public BQ:

bigquery-public-data.covid19_italy.data_by_province

enter image description here

if I run

select string_agg(      format('select %i as url_id, (%s) as simpleSKU', url_id, sql),       ' union all '   )    FROM `xxx.staging.test_query  

it returns enter image description here

https://stackoverflow.com/questions/65877988/bigquery-scripting-running-a-sql-query-based-on-each-row-included-in-a-table-co January 25, 2021 at 09:52AM

没有评论:

发表评论