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

Switch to Threaded View
Pig, mail # user - Summing the contents of a bag


Copy link to this message
-
Re: Summing the contents of a bag
Abhinav Neelam 2012-05-29, 04:00
Sorry if I've misunderstood the question but isn't this exactly what the
builtin function SUM does?
Given that your relation is contained in the alias 'in' and has this schema:
grunt> describe in;
in: {bagdata: {(int)}}

you could do this:
grunt> out = foreach in generate SUM(bagdata);
grunt> dump out;
(20)
(15)
On 29 May 2012 04:10, James Newhaven <[EMAIL PROTECTED]> wrote:

> Given a relation that contains this:
>
> ({(11),(9)})
> ({(8),(7)})
>
> Is it possible for me to SUM the contents of each bag so I get:
> (20)
> (15)
>
> Thanks,
> James
>

--
Hacking is, and always has been, the Holy
Grail of computer science.