Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Plain View
Pig, mail # user - Counting tuple elements


+
James Newhaven 2012-05-04, 16:06
Copy link to this message
-
Re: Counting tuple elements
Bill Graham 2012-05-04, 16:15
Yes, see GROUP and COUNT. Something like this:

fruits = LOAD '/my/fruit' AS (name:chararray);
grouped = GROUP fruits BY name;
counts = FOREACH grouped GENERATE group, COUNT(fruits);
DUMP counts;

On Fri, May 4, 2012 at 9:06 AM, James Newhaven <[EMAIL PROTECTED]>wrote:

> Say I have a tuple containing the following elements (Apples, Apples,
> Oranges, Carrots, Carrots)
>
> Is it possible in pig to find the counts of the tuple, for example the
> output I would like is:
>
> (Apples, 2)
> (Oranges, 1)
> (Carrots, 2)
>
> Thanks,
> James
>

--
*Note that I'm no longer using my Yahoo! email address. Please email me at
[EMAIL PROTECTED] going forward.*