Hive Unlock All Partitions

Looks like there is no good way to unlock all partitions on a hive table. That means you have to manually unlock each partition. A big pain in the butt.

This little nifty ruby snippet helps you get the unlock table statements that you can paste on your Hive CLI.

irb> s = Date.new(2014,03,01) # The start date of the partitions
irb> e = Date.new(2014,05,01) # The end date of the partitions
irb> (s..e).each {|x| puts "unlock table your_table partition(dt='#{x}');"}
unlock table your_table partition(dt='2014-04-01');
unlock table your_table partition(dt='2014-04-02');
..
unlock table your_table partition(dt='2014-05-01');
 
114
Kudos
 
114
Kudos

Now read this

Hot Swapping of Tables in Hive

Here are the steps to hot swap a table in Hive when you manually load data in them. Hot Swapping the table allows you to refresh an entire table without any downtime thus making your table always available for querying. With this... Continue →