Compiling User Defined Functions for Hive on Hadoop
While writing some fairly complicated Hive queries recently I decided to implement a section of the logic in the form of a custom User Defined Function (UDF). The instructions only cover creating the Java file and importing the compiled jar, but they do not cover a description of how to compile the UDF. I spent a while trying to include the correct jar files in both the Hadoop and Hive build directories. When I finally worked through all of the issues, I scripted the process, and I present that here for those poor souls who were in my position (I hate Java, btw):
This script is certainly not foolproof, so feel free to post corrections. One other thing to note is that for DoubleWritables you should use the one in org.apache.hadoop.hive.serde2.io.DoubleWritable instead of org.apache.hadoop.io.DoubleWritable (otherwise Hive freaks out).