Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

How to drop all the sub-partitions of a certain partition on Impala?

Highlighted

How to drop all the sub-partitions of a certain partition on Impala?

Contributor

Hello , I'm using Impala 5.9  and I would like to drop the sub-partitions of a certain partition.

For example I have a table with 2 partitioned columns, Year & Month.

So If I want to drop all the months of a certain Year I have to run the following command 12 times

ALTER TABLE  schema.Table DROP IF EXISTS PARTITION (year=2018, month='...') 

 

When I  run sth like that :

ALTER TABLE  schema.Table DROP IF EXISTS PARTITION (year=2018) in order to drop all the sub-partitions  at once It gives me the following error:

<< Items in partition spec must exactly match the partition columns in the table definition: schema.Table (1 vs 2) >>

 

Can you suggest me a way to run one command and drop many partitions at once ?

 

1 REPLY 1
Highlighted

Re: How to drop all the sub-partitions of a certain partition on Impala?

Contributor

Hi @eMazarakis,

Prior IMPALA-1654 the AlterTableDropPartitionStmt was working with PartitionSpec which is a collection of partition key/values. While from Impala 2.8+ and CDH 5.10+ IMPALA-1654 is available and the AlterTableDropPartitionStmt uses PartitionSet which can be a partition expression as well.

In CDH 5.9 and earlier the partitions have to be specified manually in the ALTER TABLE DROP PARTITION statement.

Don't have an account?
Coming from Hortonworks? Activate your account here