Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Presto map(varchar,varchar) : How to get all the possible keys for it?

Tags:

presto

I am trying to search a column having the data type map(varchar,varchar). Now one way to access the column is to use this structure, name_of_column['key'], which will give the value for that key. But I want to know what are possible keys and then apply group by and other operations based on those keys.

I tried searching on the internet but was not able to find appropriate solution.

like image 311
arman Avatar asked Mar 08 '23 15:03

arman


1 Answers

Presto offers map_keys function for that:

presto> select map_keys(map(array['alice'], array['has a cat']));
  _col0
---------
 [alice]
(1 row)
like image 132
Piotr Findeisen Avatar answered Apr 08 '23 19:04

Piotr Findeisen