2013-07-09 66 views
0

count_bool受到損害單元組,其具有下面的輸出,當我轉儲:壓扁和計數1元組

(0) 
... 
(1) 
(0) 
... 
(0) 

因此,如果有100 - (0)和20 - (1)I想要的輸出是:

(1, 20) 
(0, 100) 

這裏是我試圖拉平和計數

count_by_xy = foreach count_by_subject generate flatten($0), COUNT($0); 
2013-07-09 00:05:43,590 [main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1045: 
Could not infer the matching function for org.apache.pig.builtin.COUNT as multiple or none of them fit. Please use an explicit cast. 

什麼是我的問題嗎?

回答

0

'COLNAME' 是分配給1元組的列名:

count_group = group count_bool by colName; 

'結果' 有什麼我要找:

result = foreach count_group generate $0, COUNT(count_bool); 

$0是指第一列的值。

flatten用於取消嵌套元組,這裏不需要。