You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pig.apache.org by Jumping <qu...@gmail.com> on 2010/02/25 07:33:43 UTC

how to achive results

Hi,
I have this script, how to achive results ?


====================================================================================
A = LOAD 'file:///home/hadoop/1.csv' USING PigStorage(',') AS
(name:chararray, aa:float, bb:float, cc:float, dd:float);

B = FILTER A BY cc > 0;

C = GROUP B BY name;

D = FOREACH C GENERATE group,
SUM(B.cc)/SUM(B.aa)/SUM(B.bb) as allsum;

E= FOREACH B GENERATE cc*dd/allsum;
=====================================================================================


The last one could not work.

Looking forward to experts input. Thanks.


Best Regards,
Jumping Qu

Re: how to achive results

Posted by Jumping <qu...@gmail.com>.
Great !  I will try it.

Best Regards,
Jumping Qu


On Thu, Feb 25, 2010 at 3:35 PM, Jeff Zhang <zj...@gmail.com> wrote:

> Is this what you want ?
>
>
> A = LOAD 'data/input' USING PigStorage(',') AS
> (name:chararray, aa:float, bb:float, cc:float, dd:float);
>
> B = FILTER A BY cc > 0;
> C = GROUP B BY name;
> D = FOREACH C GENERATE group,SUM(B.cc)/SUM(B.aa)/SUM(B.bb) as allsum;
>
> E = JOIN B By name,D BY group;
>
> F = FOREACH E GENERATE name,cc*dd/allsum;
> DUMP F;
>
>
> On Thu, Feb 25, 2010 at 3:04 PM, Jumping <qu...@gmail.com> wrote:
>
> > Hi Jeff,
> >
> > Thank you for your reply so quickly.
> > I would like to  do calculations (cc * dd) * SUM (cc) / SUM (B.aa) / SUM
> > (B.bb) on  1.csv.
> >
> >
> > Best Regards,
> > Jumping Qu
> >
> > On Thu, Feb 25, 2010 at 2:50 PM, Jeff Zhang <zj...@gmail.com> wrote:
> >
> > > I am not quit understand your script. For each D there is a allSum, so
> > what
> > > is the relationship between B and allSum in your last statement.
> > >
> > >
> > >
> > > On Thu, Feb 25, 2010 at 2:33 PM, Jumping <qu...@gmail.com>
> wrote:
> > >
> > > > Hi,
> > > > I have this script, how to achive results ?
> > > >
> > > >
> > > >
> > > >
> > >
> >
> ====================================================================================
> > > > A = LOAD 'file:///home/hadoop/1.csv' USING PigStorage(',') AS
> > > > (name:chararray, aa:float, bb:float, cc:float, dd:float);
> > > >
> > > > B = FILTER A BY cc > 0;
> > > >
> > > > C = GROUP B BY name;
> > > >
> > > > D = FOREACH C GENERATE group,
> > > > SUM(B.cc)/SUM(B.aa)/SUM(B.bb) as allsum;
> > > >
> > > > E= FOREACH B GENERATE cc*dd/allsum;
> > > >
> > > >
> > >
> >
> =====================================================================================
> > > >
> > > >
> > > > The last one could not work.
> > > >
> > > > Looking forward to experts input. Thanks.
> > > >
> > > >
> > > > Best Regards,
> > > > Jumping Qu
> > > >
> > >
> > >
> > >
> > > --
> > > Best Regards
> > >
> > > Jeff Zhang
> > >
> >
>
>
>
> --
> Best Regards
>
> Jeff Zhang
>

Re: how to achive results

Posted by Jumping <qu...@gmail.com>.
Jeff,
It's work.  Thanks a lot.


Best Regards,
Jumping Qu
------
SA
BPO Solutions, China

Zhangyang Road 707, Suite 905, Shanghai, 200122, China
+86(021) 58352007-8016 Phone
+86(021) 58352007 Fax
------
Don't tell me how many enemies we have, but where they are!
(ADV:Perl -- It's like Java, only it lets you deliver on time and under
budget.)


On Thu, Feb 25, 2010 at 3:35 PM, Jeff Zhang <zj...@gmail.com> wrote:

> Is this what you want ?
>
>
> A = LOAD 'data/input' USING PigStorage(',') AS
> (name:chararray, aa:float, bb:float, cc:float, dd:float);
>
> B = FILTER A BY cc > 0;
> C = GROUP B BY name;
> D = FOREACH C GENERATE group,SUM(B.cc)/SUM(B.aa)/SUM(B.bb) as allsum;
>
> E = JOIN B By name,D BY group;
>
> F = FOREACH E GENERATE name,cc*dd/allsum;
> DUMP F;
>
>
> On Thu, Feb 25, 2010 at 3:04 PM, Jumping <qu...@gmail.com> wrote:
>
> > Hi Jeff,
> >
> > Thank you for your reply so quickly.
> > I would like to  do calculations (cc * dd) * SUM (cc) / SUM (B.aa) / SUM
> > (B.bb) on  1.csv.
> >
> >
> > Best Regards,
> > Jumping Qu
> >
> > On Thu, Feb 25, 2010 at 2:50 PM, Jeff Zhang <zj...@gmail.com> wrote:
> >
> > > I am not quit understand your script. For each D there is a allSum, so
> > what
> > > is the relationship between B and allSum in your last statement.
> > >
> > >
> > >
> > > On Thu, Feb 25, 2010 at 2:33 PM, Jumping <qu...@gmail.com>
> wrote:
> > >
> > > > Hi,
> > > > I have this script, how to achive results ?
> > > >
> > > >
> > > >
> > > >
> > >
> >
> ====================================================================================
> > > > A = LOAD 'file:///home/hadoop/1.csv' USING PigStorage(',') AS
> > > > (name:chararray, aa:float, bb:float, cc:float, dd:float);
> > > >
> > > > B = FILTER A BY cc > 0;
> > > >
> > > > C = GROUP B BY name;
> > > >
> > > > D = FOREACH C GENERATE group,
> > > > SUM(B.cc)/SUM(B.aa)/SUM(B.bb) as allsum;
> > > >
> > > > E= FOREACH B GENERATE cc*dd/allsum;
> > > >
> > > >
> > >
> >
> =====================================================================================
> > > >
> > > >
> > > > The last one could not work.
> > > >
> > > > Looking forward to experts input. Thanks.
> > > >
> > > >
> > > > Best Regards,
> > > > Jumping Qu
> > > >
> > >
> > >
> > >
> > > --
> > > Best Regards
> > >
> > > Jeff Zhang
> > >
> >
>
>
>
> --
> Best Regards
>
> Jeff Zhang
>

Re: how to achive results

Posted by Jeff Zhang <zj...@gmail.com>.
Is this what you want ?


A = LOAD 'data/input' USING PigStorage(',') AS
(name:chararray, aa:float, bb:float, cc:float, dd:float);

B = FILTER A BY cc > 0;
C = GROUP B BY name;
D = FOREACH C GENERATE group,SUM(B.cc)/SUM(B.aa)/SUM(B.bb) as allsum;

E = JOIN B By name,D BY group;

F = FOREACH E GENERATE name,cc*dd/allsum;
DUMP F;


On Thu, Feb 25, 2010 at 3:04 PM, Jumping <qu...@gmail.com> wrote:

> Hi Jeff,
>
> Thank you for your reply so quickly.
> I would like to  do calculations (cc * dd) * SUM (cc) / SUM (B.aa) / SUM
> (B.bb) on  1.csv.
>
>
> Best Regards,
> Jumping Qu
>
> On Thu, Feb 25, 2010 at 2:50 PM, Jeff Zhang <zj...@gmail.com> wrote:
>
> > I am not quit understand your script. For each D there is a allSum, so
> what
> > is the relationship between B and allSum in your last statement.
> >
> >
> >
> > On Thu, Feb 25, 2010 at 2:33 PM, Jumping <qu...@gmail.com> wrote:
> >
> > > Hi,
> > > I have this script, how to achive results ?
> > >
> > >
> > >
> > >
> >
> ====================================================================================
> > > A = LOAD 'file:///home/hadoop/1.csv' USING PigStorage(',') AS
> > > (name:chararray, aa:float, bb:float, cc:float, dd:float);
> > >
> > > B = FILTER A BY cc > 0;
> > >
> > > C = GROUP B BY name;
> > >
> > > D = FOREACH C GENERATE group,
> > > SUM(B.cc)/SUM(B.aa)/SUM(B.bb) as allsum;
> > >
> > > E= FOREACH B GENERATE cc*dd/allsum;
> > >
> > >
> >
> =====================================================================================
> > >
> > >
> > > The last one could not work.
> > >
> > > Looking forward to experts input. Thanks.
> > >
> > >
> > > Best Regards,
> > > Jumping Qu
> > >
> >
> >
> >
> > --
> > Best Regards
> >
> > Jeff Zhang
> >
>



-- 
Best Regards

Jeff Zhang

Re: how to achive results

Posted by Jumping <qu...@gmail.com>.
Hi Jeff,

Thank you for your reply so quickly.
I would like to  do calculations (cc * dd) * SUM (cc) / SUM (B.aa) / SUM
(B.bb) on  1.csv.


Best Regards,
Jumping Qu

On Thu, Feb 25, 2010 at 2:50 PM, Jeff Zhang <zj...@gmail.com> wrote:

> I am not quit understand your script. For each D there is a allSum, so what
> is the relationship between B and allSum in your last statement.
>
>
>
> On Thu, Feb 25, 2010 at 2:33 PM, Jumping <qu...@gmail.com> wrote:
>
> > Hi,
> > I have this script, how to achive results ?
> >
> >
> >
> >
> ====================================================================================
> > A = LOAD 'file:///home/hadoop/1.csv' USING PigStorage(',') AS
> > (name:chararray, aa:float, bb:float, cc:float, dd:float);
> >
> > B = FILTER A BY cc > 0;
> >
> > C = GROUP B BY name;
> >
> > D = FOREACH C GENERATE group,
> > SUM(B.cc)/SUM(B.aa)/SUM(B.bb) as allsum;
> >
> > E= FOREACH B GENERATE cc*dd/allsum;
> >
> >
> =====================================================================================
> >
> >
> > The last one could not work.
> >
> > Looking forward to experts input. Thanks.
> >
> >
> > Best Regards,
> > Jumping Qu
> >
>
>
>
> --
> Best Regards
>
> Jeff Zhang
>

Re: how to achive results

Posted by Jeff Zhang <zj...@gmail.com>.
I am not quit understand your script. For each D there is a allSum, so what
is the relationship between B and allSum in your last statement.



On Thu, Feb 25, 2010 at 2:33 PM, Jumping <qu...@gmail.com> wrote:

> Hi,
> I have this script, how to achive results ?
>
>
>
> ====================================================================================
> A = LOAD 'file:///home/hadoop/1.csv' USING PigStorage(',') AS
> (name:chararray, aa:float, bb:float, cc:float, dd:float);
>
> B = FILTER A BY cc > 0;
>
> C = GROUP B BY name;
>
> D = FOREACH C GENERATE group,
> SUM(B.cc)/SUM(B.aa)/SUM(B.bb) as allsum;
>
> E= FOREACH B GENERATE cc*dd/allsum;
>
> =====================================================================================
>
>
> The last one could not work.
>
> Looking forward to experts input. Thanks.
>
>
> Best Regards,
> Jumping Qu
>



-- 
Best Regards

Jeff Zhang