You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pig.apache.org by Matt Tanquary <ma...@gmail.com> on 2010/10/20 21:41:08 UTC
Using alias results in future calculations?
I need to use the output of one alias in a future calculation:
Suppose I have:
C=(5)
and then later, I have
G=(1,A)
(3,B)
(5,C)
then I want to do a foreach on G where I multiply each G.$0 by C.$0, ending
up with
H=(5,A)
(15,B)
(25,C)
how can I do that?
I did accomplish it by doing a CROSS against the two tables and then running
foreach against that, but I want to avoid using CROSS.
Thanks for any ideas!
-M@
--
Have you thanked a teacher today? ---> http://www.liftateacher.org
Re: Using alias results in future calculations?
Posted by Aniket Mokashi <am...@andrew.cmu.edu>.
In pig 0.8, you can say,
P = foreach G generate G.$0 * C.$0, G.$1;
Other methods are discussed here-
https://issues.apache.org/jira/browse/PIG-1434
Thanks,
Aniket
On Wed, October 20, 2010 3:41 pm, Matt Tanquary wrote:
> I need to use the output of one alias in a future calculation:
>
>
> Suppose I have:
>
>
> C=(5)
>
>
> and then later, I have
>
> G=(1,A)
> (3,B)
> (5,C)
>
>
> then I want to do a foreach on G where I multiply each G.$0 by C.$0,
> ending up with
>
> H=(5,A)
> (15,B)
> (25,C)
>
>
> how can I do that?
>
> I did accomplish it by doing a CROSS against the two tables and then
> running foreach against that, but I want to avoid using CROSS.
>
> Thanks for any ideas!
> -M@
>
>
> --
> Have you thanked a teacher today? ---> http://www.liftateacher.org
>
>