如何在pig中分组包

xjreopfe  于 2021-05-29  发布在  Hadoop
关注(0)|答案(1)|浏览(345)

关闭。这个问题需要细节或清晰。它目前不接受答案。
**想改进这个问题吗?**通过编辑这个帖子来添加细节并澄清问题。

四年前关门了。
改进这个问题
首先我有数据和我的小组

A = LOAD './test.txt' USING PigStorage(' ') AS (id:int, time:int, value:float);

B = GROUP A BY time;

例如,我有这样的结构。

1001    {(1,1001,0.2),(3,1001,0.3),(2,1001,0.3),(4,1001,0.6)}   
1002    {(2,1002,0.5),(1,1002,0.3),(3,1002,0.1),(4,1002,0.6)}  
1003    {(4,1003,0.2),(1,1003,0.8),(2,1003,0.4),(3,1003,0.5)}

但我想

1001     {(1,1001,0.2),(2,1001,0.3),(3,1001,0.3),(4,1001,0.6)}
1002     {(1,1002,0.3),(2,1002,0.5),(3,1002,0.1),(4,1002,0.6)}   
1003     {(1,1003,0.8),(2,1003,0.4),(3,1003,0.5),(4,1003,0.2)}
wljmcqd8

wljmcqd81#

使用嵌套foreach

C = FOREACH B {
          sort_by_id = ORDER A BY id;
          GENERATE group, sort_by_id ;
              };

相关问题