Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hive Partition recovery

How to recover partitions in easy fashion. Here is the scenario :

  1. Have 'n' partitions on existing external table 't'
  2. Dropped table 't'
  3. Recreated table 't' // Note : same table but with excluding some column
  4. How to recover the 'n' partitions that existed for table 't' in step #1 ?

I can manually alter table to add 'n' partition by writing some script. But that's very tedious. Is there something built-in to recover these partitions ?

like image 721
Balaji Boggaram Ramanarayan Avatar asked May 26 '16 06:05

Balaji Boggaram Ramanarayan


1 Answers

When the partitions directories still exist in the HDFS, simply run this command:

MSCK REPAIR TABLE table_name;

It adds the partitions definitions to the metastore based on what exists in the table directory.

like image 137
54l3d Avatar answered Sep 23 '22 05:09

54l3d