0

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,

1 Answer 1

1

Use concat_ws which takes accepts an array as input.

select id,concat_ws('_',first_name),concat_ws('_',last_name)
from tbl
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.