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
sai
---
| E | group::f1: int | group::f2: int | long |
---
| | 1 | 2 | 2 |
| | 1 | 3 | 1 |
| | 1 | 4
What is the structure of E and F? Can you give an illustrate or describe of
that?
2010/12/28 Michael Moss
> 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 = G
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)})
>
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
> 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,
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}) |