It so happens I have a stringified array in a field in BigQuery
'["a","b","c"]'
and I want to convert it to an array that BigQuery understands. I want to be able to do this in standard SQL:
with k as (select '["a","b","c"]' as x)
select unnested_x from k, unnest(x) unnested_x
I have tried JSON_EXTRACT('["a","b","c"]','$')
and everything else I could find online.
Any ideas?
Below is for BigQuery Standard SQL
#standardSQL
WITH k AS (
SELECT 1 AS id, '["a","b","c"]' AS x UNION ALL
SELECT 2, '["x","y"]'
)
SELECT
id,
ARRAY(SELECT * FROM UNNEST(SPLIT(SUBSTR(x, 2 , LENGTH(x) - 2)))) AS x
FROM k
It transforms your string column into array column