Post 25 | HDPCD | Register a Jar file of UDF in Apache Pig

Hello, everyone. Thanks for coming back again to continue with this certification series. In the last tutorial, we saw how to run any pig script with TEZ as the execution mode. In this tutorial, we are going to see how to register a JAR file to use the User Defined Function written and packages inside it.

Let us begin then.

For registering the jar file, we will first find out the desired jar file to register.
The jar file, for this tutorial, is called piggybank.jar file which comes with pig library.

We can use the following command to find out the path of this piggybank.jar file.

find / | grep “piggybank.jar”

You can see that the output of the above command looks as follows.

Step 1: Find an absolute path for the jar file
Step 1: Find an absolute path for the jar file

As you can see from the above screenshot that the absolute path of the jar file is /usr/hdp/2.3.0.0-2557/pig/piggybank.jar. Therefore, we can use this absolute path for registering the jar file.

For doing so, you can use the following command in the Apache Pig grunt shell.

REGISTER /usr/hdp/2.3.0.0-2557/pig/piggybank.jar;

The output of this commands looks something like this.

Step 2: Registering piggybank.jar file to the PIG session
Step 2: Registering piggybank.jar file to the PIG session

As you can see from the above screenshot, there is no output once you execute the REGISTER command. It means that the jar file was registered successfully and you do not need to worry about it.

You believe it or not, but we have reached the end of this tutorial. You can see how easy it was to successfully register the desired jar file in Apache Pig for using the User Defined Functions packaged in it.

Hope both of these commands and screenshots help you to understand the concept of Jar file registration in Apache Pig.

Please follow my blog for further updates. In the next tutorial, we are going to see how to assign an alias for a function stored in the jar file.

Please check out my website at www.milindjagre.com

You can check out my LinkedIn profile here. Please like my Facebook page here. Follow me on Twitter here and subscribe to my YouTube channel here for the video tutorials.

Advertisements

One comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s