title: Run a String through Java using Pig
body: <p>I have a UDF jar which takes in a String as an input through Pig. This java file works through pig fine as running a 'hard coded' string such as this command</p>
  
  <pre><code>B = foreach f generate URL_UDF.mathUDF('stack.overflow');
  </code></pre>
  
  <p>Will give me the output I expect</p>
  
  <p>My question is I am trying to get information from a text file and use my UDF with it. I load a file and want to pass data within that file which I have loaded to the UDF. </p>
  
  <pre><code>LoadData = load 'data.csv' using PigStorage(',');
  f = foreach LoadData generate $0 as col0, $1 as chararray
  </code></pre>
  
  <p>$1 is the column I needed and researching data types (<a href="http://pig.apache.org/docs/r0.7.0/piglatin_ref2.html#Data+Types" rel="nofollow">http://pig.apache.org/docs/r0.7.0/piglatin_ref2.html#Data+Types</a>) a char array is used.</p>
  
  <p>I then tryed using the following command 
    B = foreach f generate URL_UDF.mathUDF($1);</p>
  
  <p>to pass the data into the jar which fails stating  </p>
  
  <pre><code>java.lang.ClassCastException: org.apache.pig.data.DataByteArray cannot be cast to java.lang.String
  </code></pre>
  
  <p>If anybody has any solution to this that would be great.</p>
  
  <p>The java code I am running is as follows</p>
  
  <pre><code>package URL_UDF;
  
  import java.io.BufferedReader;
  import java.io.FileReader;
  import java.io.IOException;
  
  import java.io.InputStream;
  import java.io.InputStreamReader;
  
  import org.apache.pig.FilterFunc;
  import org.apache.pig.data.Tuple;
  import org.apache.pig.EvalFunc;
  import org.apache.pig.PigWarning;
  import org.apache.pig.data.Tuple;
  import org.apache.commons.logging.Log;
  import org.apache.*;
  
  public class mathUDF extends EvalFunc&lt;String&gt; {
  
  public String exec(Tuple arg0) throws IOException {
      // TODO Auto-generated method stub
      try{
  
          String urlToCheck = (String) arg0.get(0);
  
          return urlToCheck;
      }catch (Exception e) {
          // Throwing an exception will cause the task to fail.
          throw new IOException("Something bad happened!", e);
      }
  }
  
  }
  </code></pre>
  
  <p>Thanks</p>