How can I convert array to string in hive sql?

前端 未结 1 1145
误落风尘
误落风尘 2020-12-03 07:26

I want to convert an array to string in hive. I want to collect_set array values to convert to string without [[\"\"]].

select actor, collect_se         


        
相关标签:
1条回答
  • 2020-12-03 08:02

    Use concat_ws(string delimiter, array<string>) function to concatenate array:

    select actor, concat_ws(',',collect_set(date)) as grpdate from actor_table group by actor;
    

    If the date field is not string, then convert it to string:

    concat_ws(',',collect_set(cast(date as string)))
    

    Read also this answer about alternative ways if you already have an array (of int) and do not want to explode it to convert element type to string: How to concatenate the elements of int array to string in Hive

    0 讨论(0)
提交回复
热议问题