I am new to write custom udf for hive. I have tried writing custom udf for toupper function succecfully.
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.Text;
@Description(
name="SimpleUDFExample",
value="returns 'hello x', where x is whatever you give it (STRING)",
extended="SELECT simpleudfexample('world') from foo limit 1;"
)
class SimpleUDFExample extends UDF {
public Text evaluate(Text input) {
if(input == null) return null;
return new Text("Hello " + input.toString());
}
}
I have to write different implementations of evaluate based on different input parameters.
My query is - How can i write multiple evaluate methods in a single class.Do I need to write different classes for different methods? If i write these overridden methods in a single class then How Hive is going to differ between different method which contains same type parameter.
Please Guide me about the right way.