2017-03-07 50 views
0

的關係我有一個名爲「A」如何計算行數在豬

(name:gender:zip-code) 
(x:m:1234) 
(y:f:1234) 
(z:m:1245) 
(s:f:1235) 

我怎樣才能得到關係的行數在豬的關係?

我想要得到的結果爲4

+0

http://pig.apache.org/docs/r0.9.2/func.html#計數 和 http://stackoverflow.com/questions/9900761/pig-how-to-count-a-number-of-rows-in-alias –

回答

0

假設你的關係被命名爲A.

B = GROUP A ALL; 
B_COUNT = FOREACH B GENERATE COUNT(A); 
DUMP B_COUNT;