<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: pig - Filter output of cogroup having NULL in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/pig-Filter-output-of-cogroup-having-NULL/m-p/113376#M26028</link>
    <description>&lt;P&gt;Hi &lt;A rel="user" href="https://community.cloudera.com/users/2579/revathymurugesan.html" nodeid="2579"&gt;@Revathy Mourouguessane&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;You can use IsEmpty to check if A1 is empty or not. Try something like this &lt;/P&gt;&lt;PRE&gt;grouped = COGROUP ..... ;
filtered = FILTER grouped BY not IsEmpty($2);
DUMP filtered;
&lt;/PRE&gt;&lt;P&gt;Here's an example that shows how this work for something similar:&lt;/P&gt;&lt;PRE&gt;cat &amp;gt; owners.csv
adam,cat
adam,dog
alex,fish
david,horse
alice,cat
steve,dog

cat &amp;gt; pets.csv
nemo,fish
fido,dog
rex,dog
paws,cat
wiskers,cat

owners = LOAD 'owners.csv' USING PigStorage(',') AS (owner:chararray,animal:chararray);
pets = LOAD 'pets.csv' USING PigStorage(',') AS (name:chararray,animal:chararray);
grouped = COGROUP owners BY animal, pets by animal;
filtered = FILTER grouped BY not IsEmpty($2);

DUMP grouped;
(cat,{(alice,cat),(adam,cat)},{(wiskers,cat),(paws,cat)})
(dog,{(steve,dog),(adam,dog)},{(rex,dog),(fido,dog)})
(horse,{(david,horse)},{})
(fish,{(alex,fish)},{(nemo,fish)})

DUMP filtered;
(cat,{(alice,cat),(adam,cat)},{(wiskers,cat),(paws,cat)})
(dog,{(steve,dog),(adam,dog)},{(rex,dog),(fido,dog)})
(fish,{(alex,fish)},{(nemo,fish)})
&lt;/PRE&gt;</description>
    <pubDate>Tue, 26 Apr 2016 06:43:04 GMT</pubDate>
    <dc:creator>ahadjidj</dc:creator>
    <dc:date>2016-04-26T06:43:04Z</dc:date>
    <item>
      <title>pig - Filter output of cogroup having NULL</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/pig-Filter-output-of-cogroup-having-NULL/m-p/113375#M26027</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;This is my schema after cogroup: &lt;/P&gt;&lt;PRE&gt;C: {group: chararray,A: {(Name: chararray,Team: chararray,Positions: {T: (position: chararray)},Role: map[])},A1: {(Name1: chararray,Team1: chararray
,Points: int)}}&lt;/PRE&gt;&lt;P&gt;And I would wanted to filter out C whose A1 is empty. Like the below record:&lt;/P&gt;&lt;PRE&gt;(Jake Fox,{(Jake Fox,Chicago Cubs,{(Infielder),(Catcher),(Outfielder),(First_baseman)},[hit_by_pitch#5,games#89,on_base_percentage#0.305,grand_slams#
1,home_runs#11,sacrifice_flies#6,at_bats#230,gdb#6,ibbs#1,base_on_balls#15,hits#58,rbis#45,slugging_percentage#0.457,batting_average#0.252,doubles#14
,runs#26,strikeouts#49])},{}) &lt;/PRE&gt;&lt;P&gt;I tried nested foreach but it did not help. The output was empty bag:&lt;/P&gt;&lt;P&gt;Could someone post the query. Many Thanks!!!&lt;/P&gt;</description>
      <pubDate>Sat, 23 Apr 2016 09:44:51 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/pig-Filter-output-of-cogroup-having-NULL/m-p/113375#M26027</guid>
      <dc:creator>Eukrev</dc:creator>
      <dc:date>2016-04-23T09:44:51Z</dc:date>
    </item>
    <item>
      <title>Re: pig - Filter output of cogroup having NULL</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/pig-Filter-output-of-cogroup-having-NULL/m-p/113376#M26028</link>
      <description>&lt;P&gt;Hi &lt;A rel="user" href="https://community.cloudera.com/users/2579/revathymurugesan.html" nodeid="2579"&gt;@Revathy Mourouguessane&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;You can use IsEmpty to check if A1 is empty or not. Try something like this &lt;/P&gt;&lt;PRE&gt;grouped = COGROUP ..... ;
filtered = FILTER grouped BY not IsEmpty($2);
DUMP filtered;
&lt;/PRE&gt;&lt;P&gt;Here's an example that shows how this work for something similar:&lt;/P&gt;&lt;PRE&gt;cat &amp;gt; owners.csv
adam,cat
adam,dog
alex,fish
david,horse
alice,cat
steve,dog

cat &amp;gt; pets.csv
nemo,fish
fido,dog
rex,dog
paws,cat
wiskers,cat

owners = LOAD 'owners.csv' USING PigStorage(',') AS (owner:chararray,animal:chararray);
pets = LOAD 'pets.csv' USING PigStorage(',') AS (name:chararray,animal:chararray);
grouped = COGROUP owners BY animal, pets by animal;
filtered = FILTER grouped BY not IsEmpty($2);

DUMP grouped;
(cat,{(alice,cat),(adam,cat)},{(wiskers,cat),(paws,cat)})
(dog,{(steve,dog),(adam,dog)},{(rex,dog),(fido,dog)})
(horse,{(david,horse)},{})
(fish,{(alex,fish)},{(nemo,fish)})

DUMP filtered;
(cat,{(alice,cat),(adam,cat)},{(wiskers,cat),(paws,cat)})
(dog,{(steve,dog),(adam,dog)},{(rex,dog),(fido,dog)})
(fish,{(alex,fish)},{(nemo,fish)})
&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Apr 2016 06:43:04 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/pig-Filter-output-of-cogroup-having-NULL/m-p/113376#M26028</guid>
      <dc:creator>ahadjidj</dc:creator>
      <dc:date>2016-04-26T06:43:04Z</dc:date>
    </item>
    <item>
      <title>Re: pig - Filter output of cogroup having NULL</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/pig-Filter-output-of-cogroup-having-NULL/m-p/113377#M26029</link>
      <description>&lt;P&gt;Hi &lt;A rel="user" href="https://community.cloudera.com/users/2579/revathymurugesan.html" nodeid="2579"&gt;@Revathy Mourouguessane&lt;/A&gt;, have you tried this solution ?&lt;/P&gt;</description>
      <pubDate>Fri, 06 May 2016 00:46:34 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/pig-Filter-output-of-cogroup-having-NULL/m-p/113377#M26029</guid>
      <dc:creator>ahadjidj</dc:creator>
      <dc:date>2016-05-06T00:46:34Z</dc:date>
    </item>
    <item>
      <title>Re: pig - Filter output of cogroup having NULL</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/pig-Filter-output-of-cogroup-having-NULL/m-p/113378#M26030</link>
      <description>&lt;P&gt;Hi Abdel, I haven't tried this one. Used Join instead. I would try. Thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 06 May 2016 07:54:22 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/pig-Filter-output-of-cogroup-having-NULL/m-p/113378#M26030</guid>
      <dc:creator>Eukrev</dc:creator>
      <dc:date>2016-05-06T07:54:22Z</dc:date>
    </item>
  </channel>
</rss>

