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

What does he say when you try to drop these functions? Just silent? Anything in the logs? You can also try to use the drop ... cascade command.

DROP DATABASE IF EXISTS userdb CASCADE;

View solution in original post

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

What does he say when you try to drop these functions? Just silent? Anything in the logs? You can also try to use the drop ... cascade command.

DROP DATABASE IF EXISTS userdb CASCADE;

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.