You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pig.apache.org by 李运田 <cu...@163.com> on 2015/09/09 10:38:51 UTC

pig cogroup by null

table1
,aa
14,
12,bb


table2
,aa
14,
12,bb


k = cogroup table1 by (a,b),table2 by (a,b);
k:
((,aa),{(,aa)},{})
((,aa),{},{(,aa)})
((14,),{(14,)},{(14,)})
((12,bb),{(12,bb)},{(12,bb)})
when I use cogroup,(,aa) null is in front,(14,) null is not in front. is there a parameter I  can get result like this 
((,aa),{(,aa)},{(,aa)})
((14,),{(14,)},{(14,)})
((12,bb),{(12,bb)},{(12,bb)})
thank you.

Re: pig cogroup by null

Posted by Daniel Dai <da...@hortonworks.com>.
There is no setting, however you can rewrite your query as the following:

table1x = foreach table1 generate (a is null?'':a) as a, (b is null?'':b)
as b;
table2x = foreach table2 generate (a is null?'':a) as a, (b is null?'':b)
as b;
k = cogroup table1x by (a,b),table2x by (a,b);


Daniel

On 9/9/15, 1:38 AM, "李运田" <cu...@163.com> wrote:

>table1
>,aa
>14,
>12,bb
>
>
>table2
>,aa
>14,
>12,bb
>
>
>k = cogroup table1 by (a,b),table2 by (a,b);
>k:
>((,aa),{(,aa)},{})
>((,aa),{},{(,aa)})
>((14,),{(14,)},{(14,)})
>((12,bb),{(12,bb)},{(12,bb)})
>when I use cogroup,(,aa) null is in front,(14,) null is not in front. is
>there a parameter I  can get result like this
>((,aa),{(,aa)},{(,aa)})
>((14,),{(14,)},{(14,)})
>((12,bb),{(12,bb)},{(12,bb)})
>thank you.


Re: pig cogroup by null

Posted by Daniel Dai <da...@hortonworks.com>.
There is no setting, however you can rewrite your query as the following:

table1x = foreach table1 generate (a is null?'':a) as a, (b is null?'':b)
as b;
table2x = foreach table2 generate (a is null?'':a) as a, (b is null?'':b)
as b;
k = cogroup table1x by (a,b),table2x by (a,b);


Daniel

On 9/9/15, 1:38 AM, "李运田" <cu...@163.com> wrote:

>table1
>,aa
>14,
>12,bb
>
>
>table2
>,aa
>14,
>12,bb
>
>
>k = cogroup table1 by (a,b),table2 by (a,b);
>k:
>((,aa),{(,aa)},{})
>((,aa),{},{(,aa)})
>((14,),{(14,)},{(14,)})
>((12,bb),{(12,bb)},{(12,bb)})
>when I use cogroup,(,aa) null is in front,(14,) null is not in front. is
>there a parameter I  can get result like this
>((,aa),{(,aa)},{(,aa)})
>((14,),{(14,)},{(14,)})
>((12,bb),{(12,bb)},{(12,bb)})
>thank you.