Creating Custom UDFs
First, you need to create a new class that extends UDF, with one or more methods named evaluate.
(Note that there's already a built-in function for this, it's just an easy example).
After compiling your code to a jar, you need to add this to the Hive classpath. See the section below on deploying jars.
Once Hive is started up with your jars in the classpath, the final step is to register your function as described in Create Function:
Now you can start using it:
For a more involved example, see this page.
Deploying Jars for User Defined Functions and User Defined SerDes
In order to start using your UDF, you first need to add the code to the classpath:
By default, it will look in the current directory. You can also specify a full path:
Your jar will then be on the classpath for all jobs initiated from that session. To see which jars have been added to the classpath you can use:
See Hive CLI for full syntax and more examples.
This will add the jar to the classpath as if ADD JAR had been called on that jar.