title: How can I "group by" using a column without displaying it?
body: <p>So I have an input file named &quot;students.txt&quot; which contains the following structure: <code>id, first name, last name, date of birth</code>.
  Here is the content of it:</p>
  <pre><code>111111 Harry Cover 28/01/1986
  222222 John Doeuf 03/01/1996
  333333 Jacques Selere 18/07/1998
  444444 Jean Breille 06/08/1991
  </code></pre>
  <p>I'm trying to create a Pig script that prints all students grouped by month of birth. As of right now, I have the following user defined function (written in Java):</p>
  <pre><code>public class FormatDate extends EvalFunc&lt;DataBag&gt; {
      TupleFactory mTupleFactory = TupleFactory.getInstance();
      BagFactory mBagFactory = BagFactory.getInstance();
  
      static int id = 0 ;
      public DataBag exec(Tuple input) throws IOException {
          try {
              DataBag output = mBagFactory.newDefaultBag();
              Object o = input.get(0);
              if (!(o instanceof String)) {
                  throw new IOException(&quot;Expected input to be chararray, but got &quot; + o.getClass().getName());
              }
  
              Tuple t = mTupleFactory.newTuple(4);
              StringTokenizer tok = new StringTokenizer((String)o, &quot;/&quot;, false);
  
              int i = 0 ;
              t.set (0, id) ;
              while (tok.hasMoreTokens() &amp;&amp; i &lt; 4) {
                  i ++ ;
                  t.set (i, new String (tok.nextToken ())) ;
              }
              output.add(t);
  
              return output;
          } catch (ExecException ee) {
              // error handling goes here
          }
          return null ;
      }
  }
  </code></pre>
  <p>My current Pig script looks like this. I'm very new to this so it's probably bad.</p>
  <pre><code>REGISTER ./myudfs.jar ;
  DEFINE DATE myudfs.FormatDate ;
  R1 = LOAD 'students.txt' USING PigStorage('\t') 
       AS (stud_id : int, firstname : chararray, lastname : chararray, birthdate : chararray) ;
  R2 = DISTINCT R1 ;
  R3 = FOREACH R2 GENERATE stud_id, firstname, lastname, birthdate, FLATTEN(DATE(birthdate)) AS (id : int, day : chararray, month : chararray, year : chararray) ;
  R4 = FOREACH R3 GENERATE stud_id, firstname, lastname, birthdate, month ;
  R5 = GROUP R4 BY (month) ;
  DUMP R5;
  </code></pre>
  <p>I can't figure out how to get rid of the &quot;month&quot; column without compromising the group by line.
  Thank you in advance.</p>