Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Hive Function Drop issue

Hive Function Drop issue

New Contributor

While dropping a function using beeline -f getting the following exception

DROP FUNCTION IF EXISTS testudf.PERCENTILE_CONT;

ERROR : FAILED: error during drop function: org.apache.hadoop.hive.ql.metadata.HiveException: NoSuchObjectException(message:Function PERCENTILE_CONT does not exist) at org.apache.hadoop.hive.ql.metadata.Hive.dropFunction(Hive.java:3225) at org.apache.hadoop.hive.ql.exec.FunctionTask.dropPermanentFunction(FunctionTask.java:216) at org.apache.hadoop.hive.ql.exec.FunctionTask.execute(FunctionTask.java:90) at org.apache.hadoop.hive.ql.exec.Task.executeTask(Task.java:160) at org.apache.hadoop.hive.ql.exec.TaskRunner.runSequential(TaskRunner.java:89) at org.apache.hadoop.hive.ql.Driver.launchTask(Driver.java:1728) at org.apache.hadoop.hive.ql.Driver.execute(Driver.java:1485) at org.apache.hadoop.hive.ql.Driver.runInternal(Driver.java:1262) at org.apache.hadoop.hive.ql.Driver.run(Driver.java:1126) at org.apache.hadoop.hive.ql.Driver.run(Driver.java:1121) at org.apache.hive.service.cli.operation.SQLOperation.runQuery(SQLOperation.java:154) at org.apache.hive.service.cli.operation.SQLOperation.access$100(SQLOperation.java:71) at org.apache.hive.service.cli.operation.SQLOperation$1$1.run(SQLOperation.java:206) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAs(Subject.java:422) at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1709) at org.apache.hive.service.cli.operation.SQLOperation$1.run(SQLOperation.java:218) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: NoSuchObjectException(message:Function PERCENTILE_CONT does not exist) at org.apache.hadoop.hive.metastore.HiveMetaStore$HMSHandler.drop_function(HiveMetaStore.java:5490) at sun.reflect.GeneratedMethodAccessor84.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.apache.hadoop.hive.metastore.RetryingHMSHandler.invoke(RetryingHMSHandler.java:107) at com.sun.proxy.$Proxy8.drop_function(Unknown Source) at org.apache.hadoop.hive.metastore.HiveMetaStoreClient.dropFunction(HiveMetaStoreClient.java:2038) at sun.reflect.GeneratedMethodAccessor83.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.apache.hadoop.hive.metastore.RetryingMetaStoreClient.invoke(RetryingMetaStoreClient.java:156) at com.sun.proxy.$Proxy9.dropFunction(Unknown Source) at org.apache.hadoop.hive.ql.metadata.Hive.dropFunction(Hive.java:3223) ... 21 more Error: Error while processing statement: FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.FunctionTask (state=08S01,code=1)

2 REPLIES 2

Re: Hive Function Drop issue

@Ayoush Agarwal

NoSuchObjectException clearly indicates that the function you are trying to drop, does not exist.

Temporary Functions are required to be re-registered when starting a new session.

If you had registered your udf as a temporary function in one session and then you have ended that beeline session, then that function will get de-registered.

Now, if you will start a new beeline session and you will try to drop that same function, you will get this error.

Highlighted

Re: Hive Function Drop issue

New Contributor

@Dinesh Chitlangia, @Ayoush Agarwal, I think you may be missing the point -- he included "if exists" in his drop function notation. If the function doesn't exist, you shouldn't get an error from the statement, it should silently do nothing. This is similar to `create table if not exists xyz` -- if the table exists, the statement does nothing, if it doesn't exist, you do something. Unfortunately, there's no notation to create function if not exists, and if it does already exist, you'll get an error. The drop function notation does include an "if exists" option which means if you want to safely create a function that may already exist, you can first drop it if it does exist, and then recreate it -- however as Ayoush has demonstrated, due to the issue with the Drop implementation, you can't actually use this approach because the statement throws an exception if the function doesn't exist.

Don't have an account?
Coming from Hortonworks? Activate your account here