O
location
string é semelhante a uma matriz de texto. Converta para text[]
e desaninhar:with my_data(id, location) as (
values
(1, '["Humboldt, TN","Medina, TN","Milan, TN"]')
)
select id, unnest(format('{%s}', trim(location, '[]'))::text[]) as location
from my_data
id | location
----+--------------
1 | Humboldt, TN
1 | Medina, TN
1 | Milan, TN
(3 rows)
Ou ainda mais simples, converta a string para
jsonb
e use jsonb_array_elements_text()
:with my_data(id, location) as (
values
(1, '["Humboldt, TN","Medina, TN","Milan, TN"]')
)
select id, jsonb_array_elements_text(location::jsonb) as location
from my_data
Db<>fiddle.