Support Questions

Find answers, ask questions, and share your expertise

Drop partition remove data but not HDFS folder

avatar
Contributor

Hi,

 

We have CDH 5.15 and when we drop partition in Hive it removes the partition and its data but the folder of the partition remains empty and is not removed.

 

How can I change this behavior?

 

Thanks

3 REPLIES 3

avatar
Expert Contributor
Hi,

If it is a External table we need to delete the directory manually.

ALTER TABLE table_name DROP [IF EXISTS] PARTITION <>;
hadoop fs -rm -r <partition file path>

Thanks
Jerry

avatar
Contributor

Hi,

 

It's an internal table with 4 levels of partitions,

But still, when I remove the partition the data and metadata is deleted but not the folder.

 

Thanks

avatar
Super Guru
Hi,

I assume that you work on the managed table instead of external table? This could be because of lack of permissions from the user who tried to run the DROP command to remove the underlining HDFS path. Check HMS server log to see if you can find any error messages.