Hive: How to drop partitions by range

This is the general syntax for the drop partition syntax in Apache Hive:

 

ALTER TABLE table_name DROP [IF EXISTS] PARTITION partition_spec PURGE;

 

So the syntax to drop a range of partitions in a table that uses year as a partitioning column:

ALTER TABLE mytable DROP [IF EXISTS] PARTITION (year>2019) PURGE;

 

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.