Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Not able to drop database in hive

avatar
Guru

Hi Team,

I am not able to drop database though we do not have any table in that database ?

hive> use prashant_db;

OK

Time taken: 0.221 seconds

hive> drop database prashant_db;

FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. InvalidOperationException(message:Database prashant_db is not empty. One or more functions exist.)

hive> show tables;

OK

Time taken: 0.226 seconds

hive>

1 ACCEPTED SOLUTION

avatar
Master Guru
hide-solution

This problem has been solved!

Want to get a detailed solution you have to login/registered on the community

Register/Login
4 REPLIES 4

avatar
Guru

I can see two functions are present in database but when I am trying to drop them, those are not getting delete.

hive> drop function prashant_db.getevent;

OK

Time taken: 0.009 seconds

hive> show functions

> ;

OK

!

!=

%

&

prashant_db.getevent

prashant_db.gettheevent

printf

avatar
Master Guru
hide-solution

This problem has been solved!

Want to get a detailed solution you have to login/registered on the community

Register/Login

avatar
Guru

@Benjamin Leonhardi: Thanks a lot for your help. It worked and delete database without any error.

But can you please help me to understand why it was not deleting functions and worked with forced option(cascade) ?

hive> DROP DATABASE IF EXISTS prashant_db CASCADE;

OK

Time taken: 0.345 seconds

hive> show databases;

OK

adotest

afrankli

archive_db

baseline_db

avatar
Master Guru

So Cascade works because he forces the delete of all objects belonging to that object ( similar to delete ... cascade for row deletes )

Now the question is why your drop function did not work. And I don't know we might have to look into logs to figure that out. But I have seen flakiness with functions in hive before on an older version of hive. So it might be just a bug or a restart required or something. But again without logs hard to say.