0

I have a complex tuple with bags and tuples. How do I flatten it and access the bags?

I tried this code:

X = ({(a,b)},{(c,d),(e,f)},({(c,d),(e,f)},{g}),({(c,d),(e,f)},{h}))
Y = FOREACH X flatten($0);
Y = FOEACH Y GENERATE Y.$0;

But this doesn't seem to return the first bag.

Is there a way to return the first bag without using a UDF?

o-90
  • 17,045
  • 10
  • 39
  • 63
nnc
  • 790
  • 2
  • 14
  • 31

1 Answers1

0

I found the answer. Hope it helps someone

X = ({(a,b)},{(c,d),(e,f)},({(c,d),(e,f)},{g}),({(c,d),(e,f)},{h}))
Y = FOREACH X flatten($0) as (bag1:bag{},bag2:bag{},tuple1:tuple(),tuple2:tuple());
Y = FOEACH Y  GENERATE bag1;
nnc
  • 790
  • 2
  • 14
  • 31