Reputation: 107
I have a HIVE table as following:
id string
first_name array < string >
last_name array < string >
e.g.
id, first_name, last_name
1, [A,B], [C,D,E]
2, [A], [C,D]
How can I write a query to convert both first_name and last_name to string, as follows?
id, first_name, last_name
1, A_B, C_D_E
2, A, C_D
Thanks,
Upvotes: 0
Views: 48
Reputation: 49270
Use concat_ws
which takes accepts an array
as input.
select id,concat_ws('_',first_name),concat_ws('_',last_name)
from tbl
Upvotes: 1