- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
How to delete a particular Partition (Timestamp Based) from a hive table ? Example - Partition column value is load_s=2017-02-22 12%253A21%253A39
- Labels:
-
Apache Hadoop
-
Apache Hive
Created 03-15-2017 07:19 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Let me make it clear
HDFS Level- we have only valid partitions (parition1,parition2)
Table Level - we have both valid(parition1,partition2) and invalid partitions(partition3,partition4). I would like to drop only invalid partitions(partition3,partition4).
-> Unable to drop by passing Url encoded characters & Timestamp.
-> Created invalid partition at HDFS level, unable to drop.
-> Issued MCSK REPAIR command , post success also unable to drop.
ALTER TABLE tablename DROP PARTITION IF EXISTS (load_s='2017-02-22 12:21:39'); - did not worked.
ALTER TABLE tablename DROP PARTITION (load_s='2017-02-22 12:21:39'); - did not worked.
ALTER TABLE tablename DROP PARTITION (load_s='2017-02-22 12%3A21%3A39'); - did not worked.
Created 03-15-2017 09:08 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can you try the following:
ALTER TABLE tablename DROP PARTITION IF EXISTS (load_s=timestamp '2017-02-22 12:21:39');
Created 03-16-2017 12:54 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Deepesh - it did not worked. Getting below error.
With IF EXIST
Error: Error while compiling statement: FAILED: ParseException line 1:75 mismatched input 'IF' expecting ( near 'PARTITION' in drop partition statement (state=42000,code=40000)
Without IF EXIST -
Error: Error while compiling statement: FAILED: SemanticException Unexpected unknown partitions for (load_s = 2017-02-22 12:21:39.0) (state=42000,code=40000)
Created 03-17-2017 02:21 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
For me the command worked.
hive> show partitions tablename; OK load_s=2017-02-22 12%3A21%3A39 hive> alter table tablename drop partition (load_s=timestamp '2017-02-22 12:21:39'); Dropped the partition load_s=2017-02-22 12%3A21%3A39 OK
You can potentially use this workaround on other thread.
Created 03-28-2017 07:37 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Sankar T command given by deepesh should work. If not please share the command which you are executing and the errors logs. Before hand run this command and execute your query--> show partitions tablename;
Created 03-28-2017 07:39 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It is not working and notified to Hortonworks team. Soon I got the answer will post it here.
Created 11-16-2017 03:30 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tried this, and it worked for me,
ALTER TABLE tablename DROP IF EXISTS PARTITION (load_s=timestamp '2017-02-22 12:21:39');
The sentence "IF EXISTS" goes after the "DROP".
Regards.
Created 03-28-2017 07:07 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Adding to that , we are able to drop the partitions at HDFS level, but those invalid partitions were not dropped even after MCSK REPAIR TABLE command too.
Created 03-28-2017 07:44 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Created 03-28-2017 07:53 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Let me make it clear
HDFS Level- we have only valid partitions (parition1,parition2)
Table Level - we have both valid(parition1,partition2) and invalid partitions(partition3,partition4). I would like to drop only invalid partitions(partition3,partition4).
-> Unable to drop by passing Url encoded characters & Timestamp.
-> Created invalid partition at HDFS level, unable to drop.
-> Issued MCSK REPAIR command , post success also unable to drop.
Thanks