You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pig.apache.org by Shai Harel <sh...@mythings.com> on 2011/04/26 14:04:31 UTC

How to transform Bag to table

I have a bag of items (a result after a group operation)

(key1, {1, 2, 3})
(key2, {1, 4, 5})
...
ect

i want to generate a CROSS product on each entry
(key1, {(1,1), (1,2), (1,3), (2,2), (2,3), (3,3)})
(key1, {(1,1), (1,4), (1,5), (4,4), (4,5), (5,5)})

apparently i can't use CROSS statement  inside a FOREACH...
cr = FOREACH rr{
cr = CROSS $1.$1, $1.$1;
GENERATE cr;
}; --this is wrong...

Anybody has a suggestion?

Re: How to transform Bag to table

Posted by Shai Harel <sh...@mythings.com>.
thanks

On Tue, Apr 26, 2011 at 4:39 PM, Jacob Perkins <ja...@gmail.com>wrote:

> Nested cross is not supported at the moment, though it is in the works,
> see: https://issues.apache.org/jira/browse/PIG-1916
>
> Meanwhile, you could write a UDF to cross the items manually.
>
> --jacob
> @thedatachef
>
> On Tue, 2011-04-26 at 15:04 +0300, Shai Harel wrote:
> > I have a bag of items (a result after a group operation)
> >
> > (key1, {1, 2, 3})
> > (key2, {1, 4, 5})
> > ...
> > ect
> >
> > i want to generate a CROSS product on each entry
> > (key1, {(1,1), (1,2), (1,3), (2,2), (2,3), (3,3)})
> > (key1, {(1,1), (1,4), (1,5), (4,4), (4,5), (5,5)})
> >
> > apparently i can't use CROSS statement  inside a FOREACH...
> > cr = FOREACH rr{
> > cr = CROSS $1.$1, $1.$1;
> > GENERATE cr;
> > }; --this is wrong...
> >
> > Anybody has a suggestion?
>
>
>

Re: How to transform Bag to table

Posted by Jacob Perkins <ja...@gmail.com>.
Nested cross is not supported at the moment, though it is in the works,
see: https://issues.apache.org/jira/browse/PIG-1916

Meanwhile, you could write a UDF to cross the items manually.

--jacob
@thedatachef

On Tue, 2011-04-26 at 15:04 +0300, Shai Harel wrote:
> I have a bag of items (a result after a group operation)
> 
> (key1, {1, 2, 3})
> (key2, {1, 4, 5})
> ...
> ect
> 
> i want to generate a CROSS product on each entry
> (key1, {(1,1), (1,2), (1,3), (2,2), (2,3), (3,3)})
> (key1, {(1,1), (1,4), (1,5), (4,4), (4,5), (5,5)})
> 
> apparently i can't use CROSS statement  inside a FOREACH...
> cr = FOREACH rr{
> cr = CROSS $1.$1, $1.$1;
> GENERATE cr;
> }; --this is wrong...
> 
> Anybody has a suggestion?