1
A = load'data'as(x,y); (x,z); B =加载'数据'为(x,z);FLATTEN操作符在PIG拉丁语中的用途是什么?
C = cogroup A by x,B by x; D = foreach C生成flatten(A),flatten(b);
E =组由A :: d X
究竟在上面的语句完成,在这里我们使用实时场景扁平化。
A = load'data'as(x,y); (x,z); B =加载'数据'为(x,z);FLATTEN操作符在PIG拉丁语中的用途是什么?
C = cogroup A by x,B by x; D = foreach C生成flatten(A),flatten(b);
E =组由A :: d X
究竟在上面的语句完成,在这里我们使用实时场景扁平化。
A = load 'input1' USING PigStorage(',') as (x, y);
(x,y) --> (1,2)(1,3)(2,3)
B = load 'input2' USING PigStorage(',') as (x, z);`
(x,z) --> (1,4)(1,2)(3,2)*/
C = cogroup A by x, B by x;`
result:
(1,{(1,2),(1,3)},{(1,4),(1,2)})
(2,{(2,3)},{})
(3,{},{(3,2)})
D = foreach C generate group, flatten(A), flatten(B);`
when both bags flattened, the cross product of tuples are returned.
result:
(1,1,2,1,4)
(1,1,2,1,2)
(1,1,3,1,4)
(1,1,3,1,2)
E = group D by A::x`
here your are grouping with x column of relation A.
(1,1,2,1,4) (1,1,2,1,2) (1,1,3,1,4) (1,1,3-, 1,2)
那么在下面的答案解释,http://stackoverflow.com/questions/18544602/how-to-flatten-a-group-into-a-single-tuple-in-pig – 2015-02-12 08:20:54
它是好的FLATTEN,但我也想要示例上述语句 – 2015-02-12 09:20:57
你是什么样的例子?以上本身就是一个例子。如果你的意思是详细的描述,请查看pig docs @ https://pig.apache.org/docs/r0.7.0/piglatin_ref2.html#Flatten+Operator – 2015-02-12 09:34:53