使用hive函数对数据进行排序

使用hive函数对数据进行排序,hive,Hive,我有一张蜂巢桌 create table abc ( id int, channel string, time int ); insert into table abc values (1,'a', 12), (1,'c', 10), (1,'b', 15), (2,'a', 15), (2,'c', 12), (2,'c', 7); 我希望结果表看起来像这样- id , journey 1, c->a->b 2, c->c->a 旅程列按每个id 我试过了 se

我有一张蜂巢桌

create table abc ( id int, channel string, time int ); 

insert into table abc values
(1,'a', 12),
(1,'c', 10),
(1,'b', 15),
(2,'a', 15),
(2,'c', 12),
(2,'c', 7);
我希望结果表看起来像这样-

id , journey
1, c->a->b
2, c->c->a
旅程
列按每个
id

我试过了

select id , concat_ws(">", collect_list(channel)) as journey
from abc 
group by id

但它不保留顺序。

使用子查询和按时间排序(以保留顺序),然后在外部查询中使用collect\u列表和group by子句

hive> select id , concat_ws("->", collect_list(channel)) as journey from 
      ( 
        select * from abc order by time
       )t 
        group by id;
    +-----+----------------+--+
    | id  |    journey     |
    +-----+----------------+--+
    | 1   | 'c'->'a'->'b'  |
    | 2   | 'c'->'c'->'a'  |
    +-----+----------------+--+

如果我的数据超过1000万条记录,子查询中的订单操作的成本是多少?@Regressionor,因为我们使用的是
order By
子句,这意味着只有一个减速机将完成所有工作,因此我们将无法获得
任何并行性
,请通过在您的数据集上运行查询来进行负载测试。