Hive 如何按列进行分组

Hive 如何按列进行分组,hive,hiveql,Hive,Hiveql,我有一张桌子: class name xxx first xxx second yyy one yyy two yyy three 我希望输出为: class details xxx xxx first second yyy yyy one two three 因此,输出应该包含类以及类和名称值的串联。 由于所有字段都是字符串值,如何在配置单元中执行此操作?使用collect\u list()和group by获取每个类

我有一张桌子:

class   name
xxx     first
xxx     second
yyy     one
yyy     two 
yyy     three
我希望输出为:

class    details
xxx      xxx first second
yyy      yyy one two three
因此,输出应该包含类以及类和名称值的串联。 由于所有字段都是字符串值,如何在配置单元中执行此操作?

使用
collect\u list()
group by
获取每个类的名称值列表。最后
concat
类和详细信息以获得所需的输出

select class,concat(concat(class,' '),details) from 
(
    select class, collect_list(name) as details
    from table_name
    group BY class
)
使用
collect_list()
groupby
获取每个类的名称值列表。最后使用
concat
类和详细信息获取所需的输出

select class,concat(concat(class,' '),details) from 
(
    select class, collect_list(name) as details
    from table_name
    group BY class
)

在应用程序代码中考虑数据显示问题处理应用程序代码中的数据显示问题