假设我们在test_file
中有以下数据:
1, 3, 4
1, 5, 6
以及以下脚本:
r1 = load 'test_file' using PigStorage(',') as (a:int, b:int, c:int);
r2 = foreach r1 generate a, (b, c) as bc;
r2_group = group r2 by a;
r3 = foreach r2_group generate group as a, r2.bc as bc;
r3
如下所示:
(1, {((3, 4)), ((5,6))})
那么,我如何修改上面的脚本以生成类似下面的内容?
(1, ((3,4), (5,6)))
答案 0 :(得分:0)
看起来以下代码可以解决问题:
r4 = foreach r3 {
tmp = BagToTuple(bc);
generate a as a,
tmp as bc;
}
r4
如下所示:
(1,((5,6),(3,4)))