I have data of format in pig
{(group, productId, count)}
.
Now I want to get maximum count in each group and the output might look as follows
{(group, productId, maxCount)}
. Here is the sample input data
(south America,prod1, 45),(south America,prod2, 36), (latin america, prod1, 48),(latin america, prod5,35)
here is the output for this input look like
(south america, prod1, 45)
(North America, prod2, 36)
(latin america, prod1, 48)
can someone help me on this.
Based on your sample input data, this should do the trick:
This groups the input by first column, then in the nested foreach it orders the products per group by count, then takes the first (highest count).
Output: