title: Error while executing custom udf
body: <p>Hi I have a hive table which has got data from sqoop so there is a string field fc which has got null values. all other values are in the form of numbers.
  I have written a UDF so that I can get the value has 1000 is there is null in that column and if it is not null i should the same value.My udf code looks like below </p>
  
  <pre><code>package com.cascrmg.customudf;
  
  import org.apache.hadoop.hive.ql.exec.UDF;
  import org.apache.hadoop.io.IntWritable;
  import org.apache.hadoop.io.Text;
  
  public class sample extends UDF {
      int returnVal;
  
      // Accept a string input
      public int evaluate(Text input) {
          // If the value is null, return a 1000
          if (input == null) {
              returnVal = 1000;
          } else {
              returnVal = Integer.parseInt(input.toString());
          }
          // Lowercase the input string and return it
          return returnVal;
      }
  }
  </code></pre>
  
  <p>But when I add it and try to execute it, I get below errors.</p>
  
  <pre><code>Caused by: org.apache.hadoop.hive.ql.metadata.HiveException: Unable to execute method public int com.cascrmg.customudf.sample.evaluate(org.apache.hadoop.io.Text)  on object com.cascrmg.customudf.sample@408e96d9 of class com.cascrmg.customudf.sample with arguments {null:org.apache.hadoop.io.Text} of size 1
          at org.apache.hadoop.hive.ql.exec.FunctionRegistry.invoke(FunctionRegistry.java:993)
          at org.apache.hadoop.hive.ql.udf.generic.GenericUDFBridge.evaluate(GenericUDFBridge.java:182)
          at org.apache.hadoop.hive.ql.exec.ExprNodeGenericFuncEvaluator._evaluate(ExprNodeGenericFuncEvaluator.java:186)
          at org.apache.hadoop.hive.ql.exec.ExprNodeEvaluator.evaluate(ExprNodeEvaluator.java:77)
          at org.apache.hadoop.hive.ql.exec.ExprNodeEvaluator.evaluate(ExprNodeEvaluator.java:65)
          at org.apache.hadoop.hive.ql.exec.SelectOperator.processOp(SelectOperator.java:77)
          at org.apache.hadoop.hive.ql.exec.Operator.forward(Operator.java:815)
          at org.apache.hadoop.hive.ql.exec.TableScanOperator.processOp(TableScanOperator.java:97)
          at org.apache.hadoop.hive.ql.exec.MapOperator$MapOpCtx.forward(MapOperator.java:157)
          at org.apache.hadoop.hive.ql.exec.MapOperator.process(MapOperator.java:497)
          ... 9 more
  Caused by: java.lang.reflect.InvocationTargetException
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:497)
          at org.apache.hadoop.hive.ql.exec.FunctionRegistry.invoke(FunctionRegistry.java:969)
          ... 18 more
  Caused by: java.lang.NumberFormatException: For input string: "null"
          at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
          at java.lang.Integer.parseInt(Integer.java:580)
          at java.lang.Integer.parseInt(Integer.java:615)
          at com.cascrmg.customudf.sample.evaluate(sample.java:16)
  </code></pre>
  
  <p>Any help would be really appreciated.</p>