I created a UDF and exported the jar as abc.jar.

Copied the jar in hdfs at /user/hive/warehouse.

Now, I am getting below errors:

hive> ADD JAR /user/hive/warehouse/abc.jar;
/user/hive/warehouse/abc.jar does not exist
Query returned non-zero code: 1, cause: /user/hive/warehouse/abc.jar does not exist.
hive> 

When I do, hadoop fs -ls /user/hive, I can see abc.jar at /user/hive/warehouse path.

Where am I doing wrong and what is the solution for this?

3

There are 3 best solutions below

0
On

The way, you are mentioning the path, it will look the file in local file system.
Either place it there, or use hdfs:// like this

hive> ADD JAR /user/hive/warehouse/abc.jar   => local filesystem
hive> ADD JAR hdfs://namenodei/user/hive/warehouse/abc.jar   => In hdfs
0
On

When you add jar from hdfs you use the following statement :

ADD jar hdfs://namenode/user/hive/warehouse/abc.jar;

you are not notifying that you are adding the jar from hdfs . That is the cause of your error.

Hope that helps

1
On

Above options are valid for current sessions only. So every time you need to write ADD JAR. In order to add it permanently recommended ways are as follows.

  1. add in hive-site.xml

    <property> <name>hive.aux.jars.path</name> <value>file://localpath/yourjar.jar</value> </property>

  2. Copy and paste the JAR file to the ${HIVE_HOME}/auxlib/ folder