title: In Apache Pig, select DISTINCT rows based on a single column
body: <p>Let's say I have a table such as the one below, that may or may not contain duplicates for a given field:</p>
  
  <pre><code>ID     URL
  ---    ------------------
  001    http://example.com/adam
  002    http://example.com/beth
  002    http://example.com/beth?extra=blah
  003    http://example.com/charlie
  </code></pre>
  
  <p>I would like to write a Pig script to find only DISTINCT rows, <em>based on the value of a single field</em>. For instance, filtering the table above by <code>ID</code> should return something like the following:</p>
  
  <pre><code>ID     URL
  ---    ------------------
  001    http://example.com/adam
  002    http://example.com/beth
  003    http://example.com/charlie
  </code></pre>
  
  <p>The Pig <code>GROUP BY</code> operator returns a bag of tuples grouped by ID, which would work if I knew how to get just the first tuple per bag (perhaps a separate question).</p>
  
  <p>The Pig <code>DISTINCT</code> operator works on the entire row, so in this case all four rows would be considered unique, which is not what I want.</p>
  
  <p>For my purposes, I do not care which of the rows with ID <code>002</code> are returned.</p>