title: Group by tuple in Pig
body: <p>I've been stuck on this question for a while. I have a data file that looks like this:</p>
  
  <pre><code>(1,N,N,5,High,H,House,d)
  (1,N,N,6,High,H,House,a)    
  (2,N,N,10,Low,H,House,t)    
  (2,N,N,11,Medium,H,House,e)
  </code></pre>
  
  <p>I wanted my output in the below format. Can I achieve it using Pig???</p>
  
  <pre><code>{1,(N,N),{(5,High),(H,House),d},{(6,High),(H,House),a}}
  
  {2,(N,N),{(10,Low),(H,House),t}{(11,Medium),(H,House),e}}
  </code></pre>
  
  <p>I actually tried to group it by first column.</p>
  
  <pre><code>datafile = LOAD '/user/zbc/xyz.txt' USING PigStorage() AS (id:int, 
      flag1:chararray, flag2:chararray, typcode:chararray, typ_name:chararray, 
      groupcode:charray, groupname:chararray, date:chararray);
  
  collected = FOREACH datafile Generate TOBAG(gst_id, TOTUPLE(flag1,flag2), 
  TOBAG(TOTUPLE(typcode, typname), TOTUPLE(groupcode, groupname), date));
  </code></pre>
  
  <p>I'm not getting how to proceed further. To group by "one field and one tuple".</p>