Hive: DROP TABLE IF EXISTS <Table Name> does not free memory

Naga Vemprala picture Naga Vemprala · Mar 9, 2015 · Viewed 22.9k times · Source

When I am using DROP TABLE IF EXISTS <Table Name> in hive, it is not freeing the memory. The files are created as 0000_n.bz2 and they are still on disk.

I have two questions here:

1) Will these files keep on growing for each and every insert? 2) Is there any DROP equivalent to remove the files as well on the disk?

Answer

user3406675 picture user3406675 · Mar 9, 2015

Couple of things you can do:

  • Check if the table is an external table and in that case you need to drop the files manually on HDFS as dropping tables won't drop the files: hadoop fs -rm /HDFS_location/filename

  • Secondly check if you are in the right database. You need to issue use database command before dropping the tables. The database should be same as the one in which tables were created.