Question

I am trying to paste a string and int from map in Hive to an array. For now, record looks like this:

{"string1":1,"string2":1,"string3":15}

Is there a way to convert it to an array like this:

["string1:1","string2:1","string3:15"]
Was it helpful?

Solution

Assuming your map is called "M" and you want your array field to be called "A"

SELECT 
...
array(concat_ws(":","string1",M[1]),
      concat_ws(":","string2",M[2]),
      concat_ws(":","string3",M[3]) as A
....
FROM table;
Licensed under: CC-BY-SA with attribution
Not affiliated with datascience.stackexchange
scroll top