Hi Patcharee,

I took some liberties and constructed your starting condition 'C' from a
well formed A and B, as detailed below.  Aliases D and E resolve the inner
flattens as expected.

A = LOAD '/MYINPUTDIR' USING PigStorage('\t', '-noschema') AS
(x:int,y:int,z:int,varvalue:bag{t:tuple(varname:chararray,shape:float)});
B = GROUP A BY (x,y,z);
C = FOREACH B GENERATE FLATTEN(group) AS (x,y,z), A.varvalue AS
grouped_varvalue_bag:bag{grouped_varvalue_tuple:tuple(varvalue)};
D = FOREACH C GENERATE x,y,z, FLATTEN(grouped_varvalue_bag) AS varvalue;
E = FOREACH D GENERATE x,y,z, FLATTEN(varvalue) AS (varname,shape);

grunt>DESCRIBE E;
E: {x: int,y: int,z: int,varname: chararray,shape: float}


Please give a more detailed representation of your use case if the above
construct is not well representative of the underlying problem.

Hope this helps,

-Dan




On Wed, Apr 23, 2014 at 4:02 AM, Patcharee Thongtra <
patcharee.thong...@uni.no> wrote:

> Hi,
>
> From the schema
>
> C: {group: (int,int,int),{(varvalue: {t: (varname: chararray,shape:
> float)})}}
>
> I would like to get
>
> {int,int,int,(varname,shape)}, where there are multiple varname and shape
> value of each varname.
>
> How can I write the pig script to generate that?
>
> Patcharee
>



-- 
Dan DeCapria
CivicScience, Inc.
Back-End Data IS/BI/DM/ML Specialist

Reply via email to