title: PigLatin - Local Mode - ERROR 1066: Unable to open iterator for alias B
body: <p>I am experimenting with Pig UDFs. I am able to get simple UDF like Upper Case working for me. so I was trying to write my own UDF. I want to process each line of an input file which contains 3 integers. If the 3 integers satisfy the criteria for sides of a right angle triangle, then the hypotenuse is returned else null is returned.</p>
  
  <p>But I am getting following error - ERROR 1066: Unable to open iterator for alias B</p>
  
  <p>Here is the Pig Script Code -</p>
  
  <pre><code>-- rat.pig - A Pig script to test right angle triangle
  REGISTER /Users/admin/Programming/PigUDF/bin/myudfs/myudfs.jar;
  A = LOAD '/Users/admin/Programming/pigdata/triangle.csv' AS (sides: tuple(side_0:int, side_1:int, side_2:int));
  B = FILTER A BY (myudfs.RAT(A.sides)!= 0);
  DUMP B; 
  </code></pre>
  
  <p>The UDF is like</p>
  
  <p>package myudfs;</p>
  
  <pre><code>import java.io.IOException;
  import org.apache.pig.EvalFunc;
  import org.apache.pig.data.Tuple;
  
  public class RAT extends EvalFunc&lt;Integer&gt;{
      public Integer exec(Tuple input) throws IOException {
          if (input == null || input.size() == 0) {
              return null;
          }
          try {
              int num_0 = (Integer)input.get(0);
              int num_1 = (Integer)input.get(1);
              int num_2 = (Integer)input.get(2);
  
              if ((num_0 * num_0) + (num_1 * num_1) == num_2 * num_2) 
                  return Integer.valueOf(num_2);
              else if ((num_0 * num_0) + (num_2 * num_2) == num_1 * num_1)
                  return Integer.valueOf(num_1);
              else if ((num_1 * num_1) + (num_2 * num_2) == num_0 * num_0)
                  return Integer.valueOf(num_0);
              else {
                  return null;
              }
          } catch (Exception e) {
              throw new IOException(" Caught exception processing input row", e);
          }
      }
  
  }
  </code></pre>
  
  <p>I was wondering what I am doing wrong here. Any pointer is appreciated. Thanks.</p>