Hive 对array/数组 字段 排序

Hive 数组排序

SELECT
    memberid,
    collect_list(cast(airways as string)),
    concat_ws(',', collect_list(cast(airways as string))),
    sort_array(collect_list(cast(airways as string)))
from
    (
        select
            1 as memberid,
            'A' as airways,
            3 as legcount
        union ALL
        select
            1 as memberid,
            'B' as airways,
            2 as legcount
        union ALL
        select
            1 as memberid,
            'D' as airways,
            1 as legcount
        union ALL
        select
            1 as memberid,
            'C' as airways,
            4 as legcount
        union ALL
        select
            2 as memberid,
            'D' as airways,
            3 as legcount
        union ALL
        select
            2 as memberid,
            'C' as airways,
            4 as legcount
    ) as t
group by
    memberid;

结果:

end

相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页