我列出了男性和女性的姓名和数量。看起来像这样
ABEL 32898 82
CALLAN 1087 868
Pig计算男性总人数和女性总人数的最佳方法是什么?
答案 0 :(得分:3)
查看GROUP ALL操作:
data = LOAD 'data' AS (name:CHARARRAY, males_count:INT, females_count:INT);
data_all = GROUP data ALL;
counts = FOREACH data_all GENERATE SUM(data.males_count) AS tot_males, SUM(data.females_count) AS tot_females;