Writing Java functions for Pig can be daunting.  While it ought to be simple (it’s just Java, right?), there isn’t a clear and easy path to writing Loaders and UDFs from scratch; the documentation and examples are scattered or assume prior knowledge, and the project setup is challenging.  

To make it drop-dead easy to write UDFs and Loaders, we’ve created a maven project template with example classes for writing Pig functions. There are example UDF and Loader classes, as well as templates for various flavors of Pig Loader.  The project builds and generates a usable jar file without any changes needed.

Starting from the templates, you can write and compile a simple Loader in under five minutes.  There are some Mortar help docs that explain the various components, but the tenacious can also just replace the TODOs with working code.  

Mortar’s template project is available on github at mortardata/mortar-pig-java-template.

You can check out our help pages on writing UDFs and Loaders to get started.

Try our award-winning
Pig Platform, free


pig, java, udf,