pig-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Xavier Stevens <xstev...@mozilla.com>
Subject FOREACH and FLATTEN Syntax
Date Tue, 07 Dec 2010 19:25:53 GMT
I'm currently running into an issue where I have a bag of tuples like so:

>DUMP foo;
 ( {(a,b,c,d,e), (1,2,3,4,5)}, ... , {(f,g,h,i,j), (6,7,8,9,10)} )

Each one of the tuples has the same number of fields.  So I try to
flatten the structure so I can get just the 1st, 3rd and 4th elements of
each inner tuple.

>flat_foo = FOREACH foo GENERATE FLATTEN($0) AS (T: tuple(f1:chararray,
f2:chararray, f3:chararray, f4:chararray, f5:chararray));
>DUMP flat_foo;
(a, b, c, d, e)
(1, 2, 3, 4, 5)

>subset_foo = FOREACH flat_foo GENERATE T.f2, T.f4, T.f5;
>DUMP subset_foo;

When I do this I end up getting a casting error "ERROR 2997: Unable to
recreate exception from backed error: java.lang.ClassCastException:
java.lang.String cannot be cast to org.apache.pig.data.Tuple".

Anyone know what I am doing wrong here?



View raw message