Reputation: 4434
New to presto
, I have a table with a column contains a lot key value pairs. I can extract each row's keys using `map_keys', but I am wondering is there a function to combine and list all unique keys in one row?
SELECT
DISTINCT MAP_KEYS(col)
FROM tbl
what it looks like:
_col0
[key1, key2]
[key2, key3]
_col0
[key1, key2, key3]
Upvotes: 1
Views: 7003
Reputation: 10218
SELECT array_agg(DISTINCT k)
FROM tbl
CROSS JOIN UNNEST(map_keys(col)) AS t (k)
Upvotes: 4