title: Comparing Column values in Pig
body: <p>I am new to Pig and trying to learn Pig. I want to compare two columns to identify if a value exists in both columns. I have written a sample program in Java to do the same task. Now, I am trying to convert this program to Pig. </p>
  
  <pre><code>int [][] arr = {{1,2},{2,1},{3,2},{2,3}};
  for (int i=0; i&lt;arr.length; i++)
   for (int j=0; j&lt;arr.length; j++)
    if (arr[j][0] == arr[i][1])
     System.out.println("found");
    else
     System.out.println("not found");
  </code></pre>
  
  <p>So far, I have written</p>
  
  <pre><code>grunt&gt; read_file = LOAD 'file.txt' AS (i:int, j:int);
  grunt&gt; DUMP read_file;
  (1,2)
  (2,1)
  (3,2)
  (2,3)
  grunt&gt; grp = GROUP read_file BY $0;
  grunt&gt; dump grp;
  (1,{(1,2)})
  (2,{(2,1),(2,3)})
  (3,{(3,2)})
  </code></pre>
  
  <p>Comparing first value of int with second values in bag for each relation should get me same results.</p>