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

Two Very Useful Hive CLI settings

It is very helpful to set these in your .hiverc file. The hive cli reads from the .hiverc file in your home directory to override defaults. Two of the settings I find very important is set hive.cli.print.header=true; set... Continue →