[Solved-2 Solutions] Pig: Get top n values per group ?
Problem :
The below data is already grouped and aggregated.
- For every user (wiki and tiki), we want to retrieve their top n values (let's say 2), sorted terms of 'count'. So the desired output want it to be:
How can we accomplish that?
Solution 1:
- The below code is helps to get n values
Input :
Output :
Solution 2:
Here is an example
- top is an inbuilt function and may throw an error so the only thing which we did was changed the name of the relation in this case and instead of
Output:
Modified that as shown below -
Output: