Support Questions

Find answers, ask questions, and share your expertise

Permanently added UDF doesn't work with ODBC connection

avatar
Expert Contributor

I'm using the Hortonworks Hive ODBC driver in my application.

I did: CREATE FUNCTION MyFunc as 'com.my.udf.class' USING JAR 'hdfs:///user/location/to/my.jar';

That worked. Ehen I close my HiveCLI session and open it back up, I can immediately run SELECT myfunc(data) FROM tbl; and it loads the class and functions correctly. However it doesn't work inside of HUE or in my ODBC connection within my app.

1 ACCEPTED SOLUTION

avatar
Contributor

Both Hue /ODBC make use of HiveServer2. You might want to check the HiveServer2 logs to see if there are any errors when running these queries. Is the HDFS location of your JAR accessible to the "hive" user (or whatever user is running HiveServer2)?

View solution in original post

13 REPLIES 13

avatar
Contributor

Can you give details of how it doesn't work? Does it not find the function, or find the function and fail to execute it properly?

avatar
Expert Contributor

Sorry, yeah using HUE or through my ODBC application it says it can't find the function. I'm logging into the application in HUE with the same username I am with through the HiveCLI.

To be specific:

Error occurred executing hive query: Error while compiling statement: FAILED: SemanticException [Error 10011]: Line 1:155 Invalid function

avatar
Contributor

Both Hue /ODBC make use of HiveServer2. You might want to check the HiveServer2 logs to see if there are any errors when running these queries. Is the HDFS location of your JAR accessible to the "hive" user (or whatever user is running HiveServer2)?

avatar
Expert Contributor

Logging in with the same username with Hue as I am with HiveCLI. Getting this error

Error occurred executing hive query: Error while compiling statement: FAILED: SemanticException [Error 10011]: Line 1:155 Invalid function

avatar
Contributor

What database was the function created under (permanent functions are qualified with a database name). If you did not specify the DB name when you created it, it would have automatically used the current DB. Do you see the fully qualified function name when you run SHOW FUNCTIONS?

avatar
Expert Contributor

It was not created with a specific database. If I run SHOW FUNCTION within the HiveCLI it shows up as default.<myfunction>. If I run SHOW FUNCTION in Hue, the function does NOT show up even though I'm using the "default" database. Is there a way I can make it not be under "default." and just "<function>"? Hue/App using ODBC has no problem using those functions (e.g. count()).

If I add the jar file in Hue (one the left sidebar) and the function/class information it all works.

avatar
Contributor

There was supposed to be a RELOAD FUNCTIONS command to refresh the function list if the function was created in a different environment from the current one like what you have done here. However it looks like this command was not working properly in HDP 2.3. It was fixed in HIVE-13043.

The workaround for HDP 2.3 would be to restart HiveServer2, or to create the function in Hue/ODBC rather than in a separate HiveCLI.

avatar
Expert Contributor

I can't seem to reply to your last comment but that was exactly the problem.

avatar

@Kevin Vasko @jdere Can you check if hive.server2.enable.doAs is set to True ?

Also, check this JIRA

https://issues.apache.org/jira/browse/HIVE-5160

Which version of Hive you are using ?