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