Think of bags as collections of rows, and Tuples as collections of fields. When you flatten the bag, you dump out a bunch of rows (which is what you are observing).. what you really want is something like a UDF BagToTuple (this is a hypothetical UDF, you'd have to write it), and then to flatten said Tuple, which will give you a collection of fields.
D On Tue, Dec 28, 2010 at 1:41 PM, Michael Moss <[email protected]>wrote: > --------------------------------------------------- > | E | group::f1: int | group::f2: int | long | > --------------------------------------------------- > | | 1 | 2 | 2 | > | | 1 | 3 | 1 | > | | 1 | 4 | 1 | > | | 1 | 5 | 1 | > --------------------------------------------------- > --------------------------------------------------------------------- > | F | group: int | E: bag({group::f1: int,group::f2: int,long}) | > --------------------------------------------------------------------- > | | 1 | {(1, 2, 2), ..., (1, 5, 1)} | > --------------------------------------------------------------------- > -------------------------------------------------- > | G | group: int | f2: bag({group::f2: int}) | > -------------------------------------------------- > | | 1 | {(2), ..., (5)} | > -------------------------------------------------- > > > On Tue, Dec 28, 2010 at 4:38 PM, Jonathan Coveney <[email protected] > >wrote: > > > What is the structure of E and F? Can you give an illustrate or describe > of > > that? > > > > 2010/12/28 Michael Moss <[email protected]> > > > > > Thanks, Jonathan. > > > > > > This gives me: > > > (1,2) > > > (1,3) > > > (1,4) > > > (1,5) > > > > > > I'm wondering if it's possible to get: > > > 1,2,3,4,5 > > > > > > Maybe I need to address it further up in my script? > > > >F = GROUP E BY f1; > > > >DESCRIBE F; > > > F: {group: int,E: {group::f1: int,group::f2: int,long}} > > > >DUMP F; > > > (1,{(1,2,5),(1,3,4),(1,4,3),(1,5,1)}) > > > > > > >G = FOREACH F GENERATE group, E.f2; > > > >DESCRIBE G; > > > G: {group: int,f2: {group::f2: int}} > > > > > > Can I go from F to: > > > 1,2,3,4,5 > > > ? > > > > > > > > > > > > > > > On Tue, Dec 28, 2010 at 3:36 PM, Jonathan Coveney <[email protected] > > > >wrote: > > > > > > > L = FOREACH G GENERATE group, FLATTEN(f2); > > > > > > > > That should do it. Did you try that? Is there any reason it did not? > > > > > > > > 2010/12/28 Michael Moss <[email protected]> > > > > > > > > > Hello, All. > > > > > > > > > > I have what I hope is a quick, noob question, but I am having > trouble > > > > > flattening one of my relations, G. > > > > > > > > > > >DESCRIBE G; > > > > > G: {group: int,f2: {group::f2: int}} > > > > > > > > > > >ILLUSTRATE G; > > > > > -------------------------------------------------- > > > > > | G | group: int | f2: bag({group::f2: int}) | > > > > > -------------------------------------------------- > > > > > | | 1 | {(2), ..., (5)} | > > > > > | | 2 | {(3), (4), (5)} | > > > > > | | 3 | {(4), (5)} | > > > > > | | 4 | {(5)} | > > > > > -------------------------------------------------- > > > > > > > > > > > > > > > >DUMP G; > > > > > (1,{(2),(3),(4),(5)}) > > > > > > > > > > The problem is, when I dump this to a file, I have: > > > > > 1,{(2),(3),(4),(5)} > > > > > > > > > > I'd like to end up with: > > > > > 1,2,3,4,5 > > > > > > > > > > Is this possible? > > > > > > > > > > Thanks. > > > > > > > > > > > > > > >
