Hive 的 collect_list 是有序的吗?

Is Hive's collect_list ordered?

This page 说 collect_list:

Returns a list of objects with duplicates.

那个列表是有序的吗?比如查询结果的顺序?

built-in collect_list 不能保证被订购,即使你先做了一个 order by (即使它 did 确保顺序,这样做是浪费时间)。只需使用 brickhouse collect;它确保元素有序。

collect_list 不能保证一定会被订购是正确的。函数 sort_array 将对结果进行排序:

   select a, b, sort_array(collect_list(c)) as sorted_c
   from the_table
   group by a, b