从配置单元中的非嵌套数据创建嵌套数据

create nested data from from un-nested data in hive

有什么方法可以根据非嵌套数据在配置单元中创建嵌套数据

示例: 来源 table

id zip_code
123 12345
123 23456
123 56789
234 12345
234 99999

看起来像这样

id zipcode
123 12345,23456,56789
234 12345,99999

请注意,一个 id 的邮政编码数量可能会有所不同

select id
     , concat_ws(',',collect_set(zip_code)) as zipcode 
  from your_table 
 group by id

collect_set() 将删除 zip_code 集合中的重复项。如果您需要重复,请使用 collect_list 而不是