You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pig.apache.org by prasenjit mukherjee <pr...@gmail.com> on 2009/10/12 13:38:16 UTC

how to define 2 tables in a statement

I woudl like to create 2 separate tables in a single pass ( i.e. in a
single foreach statement). For example :

r0 = load 'foo';
tab1 = foreach r0 generate f1
tab2 = foreach r0 generate f2,f3,f6

The above statement goes over r0 in 2 passes. Is there a way to do it
in a single pass/foreach ?

-Prasen

Re: how to define 2 tables in a statement

Posted by prasenjit mukherjee <pr...@gmail.com>.
I think split ( what you are referring to )  divides the data by rows.
 What I want is to split on columns.

On Mon, Oct 12, 2009 at 6:30 PM, Tamir Kamara <ta...@gmail.com> wrote:
> Hi,
>
> You can use split with an always true condition
> split a into b1 if 0 == 0, b2 if 0 == 0;
>
> Tamir
>
> On Mon, Oct 12, 2009 at 1:38 PM, prasenjit mukherjee
> <pr...@gmail.com>wrote:
>
>> I woudl like to create 2 separate tables in a single pass ( i.e. in a
>> single foreach statement). For example :
>>
>> r0 = load 'foo';
>> tab1 = foreach r0 generate f1
>> tab2 = foreach r0 generate f2,f3,f6
>>
>> The above statement goes over r0 in 2 passes. Is there a way to do it
>> in a single pass/foreach ?
>>
>> -Prasen
>>
>

Re: how to define 2 tables in a statement

Posted by Tamir Kamara <ta...@gmail.com>.
Hi,

You can use split with an always true condition
split a into b1 if 0 == 0, b2 if 0 == 0;

Tamir

On Mon, Oct 12, 2009 at 1:38 PM, prasenjit mukherjee
<pr...@gmail.com>wrote:

> I woudl like to create 2 separate tables in a single pass ( i.e. in a
> single foreach statement). For example :
>
> r0 = load 'foo';
> tab1 = foreach r0 generate f1
> tab2 = foreach r0 generate f2,f3,f6
>
> The above statement goes over r0 in 2 passes. Is there a way to do it
> in a single pass/foreach ?
>
> -Prasen
>

Re: how to define 2 tables in a statement

Posted by prasenjit mukherjee <pr...@gmail.com>.
Aha, Thanks to Alan and Nikhil, that clears my doubt.

On Mon, Oct 12, 2009 at 11:10 PM, Nikhil Gupta <gu...@gmail.com> wrote:
> In addition, you can probably look at the generated execution plan for the
> script - just to be sure.
> -nikhil
> http://comimix.com
>
> On Mon, Oct 12, 2009 at 9:22 AM, Alan Gates <ga...@yahoo-inc.com> wrote:
>
>> As of pig 0.3.0 Pig will put an implicit split in the example script and
>> only run over the data once.  There are certain operations (like joins) that
>> can prevent this, but in most cases it will happen automatically.
>>
>> Alan.
>>
>>
>> On Oct 12, 2009, at 4:38 AM, prasenjit mukherjee wrote:
>>
>>  I woudl like to create 2 separate tables in a single pass ( i.e. in a
>>> single foreach statement). For example :
>>>
>>> r0 = load 'foo';
>>> tab1 = foreach r0 generate f1
>>> tab2 = foreach r0 generate f2,f3,f6
>>>
>>> The above statement goes over r0 in 2 passes. Is there a way to do it
>>> in a single pass/foreach ?
>>>
>>> -Prasen
>>>
>>
>>
>

Re: how to define 2 tables in a statement

Posted by Nikhil Gupta <gu...@gmail.com>.
In addition, you can probably look at the generated execution plan for the
script - just to be sure.
-nikhil
http://comimix.com

On Mon, Oct 12, 2009 at 9:22 AM, Alan Gates <ga...@yahoo-inc.com> wrote:

> As of pig 0.3.0 Pig will put an implicit split in the example script and
> only run over the data once.  There are certain operations (like joins) that
> can prevent this, but in most cases it will happen automatically.
>
> Alan.
>
>
> On Oct 12, 2009, at 4:38 AM, prasenjit mukherjee wrote:
>
>  I woudl like to create 2 separate tables in a single pass ( i.e. in a
>> single foreach statement). For example :
>>
>> r0 = load 'foo';
>> tab1 = foreach r0 generate f1
>> tab2 = foreach r0 generate f2,f3,f6
>>
>> The above statement goes over r0 in 2 passes. Is there a way to do it
>> in a single pass/foreach ?
>>
>> -Prasen
>>
>
>

Re: how to define 2 tables in a statement

Posted by Alan Gates <ga...@yahoo-inc.com>.
As of pig 0.3.0 Pig will put an implicit split in the example script  
and only run over the data once.  There are certain operations (like  
joins) that can prevent this, but in most cases it will happen  
automatically.

Alan.

On Oct 12, 2009, at 4:38 AM, prasenjit mukherjee wrote:

> I woudl like to create 2 separate tables in a single pass ( i.e. in a
> single foreach statement). For example :
>
> r0 = load 'foo';
> tab1 = foreach r0 generate f1
> tab2 = foreach r0 generate f2,f3,f6
>
> The above statement goes over r0 in 2 passes. Is there a way to do it
> in a single pass/foreach ?
>
> -Prasen