Created on 04-05-2016 06:39 AM - edited 09-16-2022 03:12 AM
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>
Created 04-05-2016 07:36 AM
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;
Created 04-05-2016 06:54 AM
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
Created 04-05-2016 07:36 AM
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;
Created 04-05-2016 09:45 AM
@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
Created 04-05-2016 10:18 AM
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.