You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pig.apache.org by 唐亮 <le...@gmail.com> on 2011/08/17 01:11:32 UTC

Can I Use a Nested GROUP in FOREACH?

Hi group,
Can I use a nested group in foreach?

For example:

A = load data ... as (a1:..., a2:..., a3:..., ...)
B = group A by a1;

C = foreach B {
 * inner_group = group A by a2;*
  generate group, inner_group;
}

As the emphasized sentence,
can I group the inner bag again from relation B?

But the compiler complained 'group' is an invalid alias in 'inner_group' of
relation C.

So, can I or how can I use a nested group in foreach?

Thanks!!

Re: Can I Use a Nested GROUP in FOREACH?

Posted by Thejas Nair <th...@hortonworks.com>.
The GSOC project adds support for a foreach inside a nested-foreach 
block. https://issues.apache.org/jira/browse/PIG-2150 . It should be 
part of 0.10 .

But group inside foreach is not supported yet.

-Thejas


On 8/17/11 9:02 AM, Jonathan Coveney wrote:
> I believe there is someone doing google summer of code on this very issue.
>
> 2011/8/16 唐亮<le...@gmail.com>
>
>> Hi group,
>> Can I use a nested group in foreach?
>>
>> For example:
>>
>> A = load data ... as (a1:..., a2:..., a3:..., ...)
>> B = group A by a1;
>>
>> C = foreach B {
>>   * inner_group = group A by a2;*
>>   generate group, inner_group;
>> }
>>
>> As the emphasized sentence,
>> can I group the inner bag again from relation B?
>>
>> But the compiler complained 'group' is an invalid alias in 'inner_group' of
>> relation C.
>>
>> So, can I or how can I use a nested group in foreach?
>>
>> Thanks!!
>>
>


Re: Can I Use a Nested GROUP in FOREACH?

Posted by Jonathan Coveney <jc...@gmail.com>.
I believe there is someone doing google summer of code on this very issue.

2011/8/16 唐亮 <le...@gmail.com>

> Hi group,
> Can I use a nested group in foreach?
>
> For example:
>
> A = load data ... as (a1:..., a2:..., a3:..., ...)
> B = group A by a1;
>
> C = foreach B {
>  * inner_group = group A by a2;*
>  generate group, inner_group;
> }
>
> As the emphasized sentence,
> can I group the inner bag again from relation B?
>
> But the compiler complained 'group' is an invalid alias in 'inner_group' of
> relation C.
>
> So, can I or how can I use a nested group in foreach?
>
> Thanks!!
>