开发者

Adding values using PIG

开发者 https://www.devze.com 2023-03-20 20:14 出处:网络
I have a list of names and 开发者_StackOverflowcounts for males and females. Looking like this ABEL3289882

I have a list of names and 开发者_StackOverflowcounts for males and females. Looking like this

ABEL 32898 82

CALLAN 1087 868

What is the best way in Pig to count up the total number of males and the total number of females?


Have a look to the GROUP ALL operation:

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;
0

精彩评论

暂无评论...
验证码 换一张
取 消