I have a JSON column points
of type VARCHAR in a table which I want to parse in Presto. For example:
points = {"0": 0.2, "1": 1.2, "2": 0.5, "15": 1.2, "20": 0.7}
I want to select only the values for keys "0", "2" and "20"
. How do I use the UNNEST functionality of Presto to get them. What I've done till now is:
select t.value from myTable CROSS JOIN UNNEST(points) AS t(key, value) limit 1
But this gives this error:
Cannot unnest type: varchar
Update:
I ran the following query and got the result but it is returning one random key-value pair from the JSON whereas I need specific keys.
select key, value from myTable CROSS JOIN UNNEST(SPLIT_TO_MAP(points, ',', ':')) AS t(key, value) limit 1