1
$\begingroup$

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"]
$\endgroup$
2
$\begingroup$

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;
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.