1

I am not able to drop partition in hive table.

ALTER TABLE db.table drop if exists partition(dt="****-**-**/id=**********");
OK
Time taken: 0.564 seconds

But partitions are not getting deleted

Below is the what I get when I check partitions of my table:

hive> show partitions db.table;
OK
dt=****-**-**/id=**********
dt=****-**-**/id=**********
dt=****-**-**/id=**********
dt=****-**-**/id=**********

After running Alter table db.table drop if exists command it should actually delete the partition . But it is not happening so .

Can you please suggest me on this. Thanks in advance.

leftjoin
  • 36,950
  • 8
  • 57
  • 116

2 Answers2

1

Try this:

ALTER TABLE db.table drop if exists partition(dt='****-**-**', id='**********');
leftjoin
  • 36,950
  • 8
  • 57
  • 116
1

As @leftjoin also mentioned, you have to specify partitions with comma seperated.

ALTER TABLE page_view DROP if exists PARTITION (dt='****-**-**', id='**********');

Please note -

In Hive 0.7.0 or later, DROP returns an error if the partition doesn't exist, unless IF EXISTS is specified or the configuration variable hive.exec.drop.ignorenonexistent is set to true.

Due to this reason, your query didn't fail and returned OK response.

Nishu Tayal
  • 20,106
  • 8
  • 49
  • 101