Support Questions

Find answers, ask questions, and share your expertise

How do I add files/jar's through hive view @ambari?

avatar

We are experiencing a problem when trying to add jar’s/files via hive view @ ambari. However when we perform the same commands via CLI it works.

Can anyone help me on this?

1 ACCEPTED SOLUTION

avatar
Master Mentor

@Cristina Lopes

the following syntax was tested on sandbox in Hive view, assuming I have a UDF JAR called HiveSimpleUdf-1.0-SNAPSHOT.jar with class name com.hortonworks.hive.SimpleUDFgetRegionUS,

# upload JAR file into /tmp/udfs on hdfs, using hdfs dfs -put command or Ambari files view

SELECT "California" as State;

CREATE TEMPORARY FUNCTION getRegionUS AS 'com.hortonworks.hive.SimpleUDFgetRegionUS' USING JAR 'hdfs:///tmp/udfs/HiveSimpleUdf-1.0-SNAPSHOT.jar';

LIST JARS;

SELECT "California" as State, getRegionUS("California") as Region;

DROP FUNCTION getRegionsUS;

CREATE FUNCTION getRegionUS AS 'com.hortonworks.hive.SimpleUDFgetRegionUS' USING JAR 'hdfs:///tmp/udfs/HiveSimpleUdf-1.0-SNAPSHOT.jar';

LIST JARS;

SELECT DISTINCT getRegionUS(split(user.userlocation, ",")[0]) FROM TWEETS;

View solution in original post

7 REPLIES 7

avatar
Master Mentor

@Cristina Lopes

the following syntax was tested on sandbox in Hive view, assuming I have a UDF JAR called HiveSimpleUdf-1.0-SNAPSHOT.jar with class name com.hortonworks.hive.SimpleUDFgetRegionUS,

# upload JAR file into /tmp/udfs on hdfs, using hdfs dfs -put command or Ambari files view

SELECT "California" as State;

CREATE TEMPORARY FUNCTION getRegionUS AS 'com.hortonworks.hive.SimpleUDFgetRegionUS' USING JAR 'hdfs:///tmp/udfs/HiveSimpleUdf-1.0-SNAPSHOT.jar';

LIST JARS;

SELECT "California" as State, getRegionUS("California") as Region;

DROP FUNCTION getRegionsUS;

CREATE FUNCTION getRegionUS AS 'com.hortonworks.hive.SimpleUDFgetRegionUS' USING JAR 'hdfs:///tmp/udfs/HiveSimpleUdf-1.0-SNAPSHOT.jar';

LIST JARS;

SELECT DISTINCT getRegionUS(split(user.userlocation, ",")[0]) FROM TWEETS;

avatar

many thanks 🙂 it worked perfectly for .jar

When we try to add a file for example a GeoIP2 Database it gives the following error "H110 Unable to submit statement. Error while processing statement: null [ERROR_STATUS]"

avatar
Master Mentor

I cannot test now but try the command below. I'm not sure all CLI commands work in Ambari view. Try any from https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Cli

source /path/filename;

avatar
Master Guru

Hi @Cristina Lopes, you can add your jar and other files to HDFS using the Files view, then go back to the Hive view and write your Hive scripts refering to those files. If you have some specific problems please let us know.

avatar

We have done the upload of both .jar and other file (a .dat file), for .jar worked for the other it gives the following error "H110 Unable to submit statement. Error while processing statement: null [ERROR_STATUS]"

avatar
Contributor

Hi,

I tried out adding the jars that are present in hdfs using the hive view as follows

add jar 'hdfs:///tmp/udfs/hive/esri-geometry-api.jar';

But I am getting this error

Error while compiling statement: FAILED: ParseException line 4:0 cannot recognize input near 'add' 'jar' ''hdfs:///tmp/udfs/hive/esri-geometry-api.jar'' [ERROR_STATUS

I also tried to add jar like

add jar /tmp/udfs/hive/esri-geometry-api.jar;

Still I get the same error.

I am not able to add these spatial jars that i need . Can you help me out in that regard?

the image below shows the jars in the path as shown.

6471-capture.png

avatar

@Srinivas Santhanam I guess you would have figured out by now. For others, the problem with above query is quotes in hdfs path, try without quote like below

add jar hdfs:///tmp/udfs/hive/esri-geometry-api.jar