I have data for 4 years. Like
'2011
2012
2013
2014'
I have to run queries based on one month's data. So i am creating partitions as below.
'ALTER TABLE table1_2010Jan ADD PARTITION(year='2010', month='01', day='01')
LOCATION 'path';
ALTER TABLE table1_2010Jan ADD PARTITION(year='2010', month='01', day='02')
LOCATION 'path';
ALTER TABLE table1_2010Jan ADD PARTITION(year='2010', month='01', day='03')
LOCATION 'path';'
I am creating individual partitions like above for every day of every month.
I want to know if we can write a script(any language) an run it one time to create these partitions for the all the days of a month for every year? Or is there a way to do this in hive itself.
Any suggestions please..
For external table , hive can not do it. You can create shell/perl script to to do the same (using loop).
For hive managed table, you can do it easily using MSCK REPAIR command.
Only thing you have to ensure that the data is loaded is correct partition.
来源:https://stackoverflow.com/questions/23766449/creating-hive-partitions-for-multiple-months-using-one-script