I have a hive table like
a b
-------------
1 2
3 4
How can I create a map column c
c
-----------
1: 2
3: 4
where column a
is the keys and column b
is the values?
CodePudding user response:
Use map() construct in Hive:
select map(a,b) as c from mytable
In Presto you can use map(array[key], array[value])
select map(array[a],array[b]) as c from mytable
Or map_agg()
select map_agg(a,b) as c from mytable group by a,b