You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pig.apache.org by "Sai Krishna Kalyan (GSS BLR)" <sa...@nousinfo.com> on 2014/02/20 11:49:03 UTC

PIG Script to aggregate data while grouping

This is my input data in PIG.
(sick,21-05-2013)
(sick,21-05-2013)
(sick,21-05-2013)
(sick,17-05-2013)
(sick,19-05-2013)
for the following relation
H = foreach G generate word,date;
What script should i write to get my output as
(sick,21-05-2013,3)
(sick,17-05-2013,1)
(sick,19-05-2013,1)
I am totally confused not able to rack my brains around it. Help!

________________________________
NOUS INFOSYSTEMS DISCLAIMER : This e-mail transmission may contain confidential or legally privileged information that is intended only for the individual(s) or entity(ies) named in the e-mail address. If you are not the intended recipient, please reply to the postmaster@nousinfo.com, so that arrangements can be made for proper delivery, and then please delete all copies and attachments. Any disclosure, copying, distribution, or reliance upon the contents of this e-mail, by any other than the intended recipients, is strictly prohibited.

Re: PIG Script to aggregate data while grouping

Posted by praveenesh kumar <pr...@gmail.com>.
You need something like this ?

I = Group H by (word,date);
J = FOREACH I generate group,COUNT($1);
dump J;

Regards
Prav

On Thu, Feb 20, 2014 at 10:49 AM, Sai Krishna Kalyan (GSS BLR) <
saikrishnak@nousinfo.com> wrote:

> This is my input data in PIG.
> (sick,21-05-2013)
> (sick,21-05-2013)
> (sick,21-05-2013)
> (sick,17-05-2013)
> (sick,19-05-2013)
> for the following relation
> H = foreach G generate word,date;
> What script should i write to get my output as
> (sick,21-05-2013,3)
> (sick,17-05-2013,1)
> (sick,19-05-2013,1)
> I am totally confused not able to rack my brains around it. Help!
>
> ________________________________
> NOUS INFOSYSTEMS DISCLAIMER : This e-mail transmission may contain
> confidential or legally privileged information that is intended only for
> the individual(s) or entity(ies) named in the e-mail address. If you are
> not the intended recipient, please reply to the postmaster@nousinfo.com,
> so that arrangements can be made for proper delivery, and then please
> delete all copies and attachments. Any disclosure, copying, distribution,
> or reliance upon the contents of this e-mail, by any other than the
> intended recipients, is strictly prohibited.
>