Hive 对array/数组 字段 排序

Posted 二十六画生的博客

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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

以上是关于Hive 对array/数组 字段 排序的主要内容,如果未能解决你的问题,请参考以下文章

PHP二维数组怎么按某个字段排序

Array.Sort 谷歌内核 数组大小超过10 排序字段都一致 返回的数组非原数组

PHP中根据二维数组中某个字段实现排序

usort 对多个字段进行排序

PHP:根据二维数组中的某个字段进行排序

Hive获取array数组长度