Hive External Table - Drop Partition

2.1k views Asked by At

Facing a weird issue. Alter table command to drop partition works well for > or < or >= or <= signs but not for = check.

Working command:

ALTER TABLE XYZ DROP PARTITION(bizdate>'20231230');

Command that's not working and throwing an error stating that partition does not exist:

ALTER TABLE XYZ DROP PARTITION(bizdate='20231230');

When I do show partitions, I can see '20231230' partition.

Note: bizdate is a varchar(10)

1

There are 1 answers

0
Skanda Shastry On

Check the list of partition in the table:

SHOW PARTITIONS <table>;

Perhaps it tries dropping the partition. It seems that the data was removed at some point on HDFS but the hive tables metadata still thinks those partitions exist

 ALTER TABLE *tableName* drop if exists PARTITION(bizdate="20231230");

& Re-pair the broken table

msck repair table *table_name*;