This is a simple PigScript i wrote to understand the concepts of pig.
Well here it goes
Today we will see how to do a simple sum operation in Pig.
Consider this as my input data
.
The first example - sum
The second example - group and sum
Well here it goes
Today we will see how to do a simple sum operation in Pig.
Consider this as my input data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 | |
2 | |
3 | |
4 | |
1 | |
1 | |
1 |
The first example - sum
The second example - group and sum
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Plain Sum | |
B = group A All; | |
C = foreach B generate SUM($1); | |
dump C; | |
-- Group And Sum | |
A = load 'input' as (number:int); | |
B = group A by $0; | |
C = foreach B generate SUM($1); | |
dump C; |
No comments:
Post a Comment