Created
March 4, 2016 07:24
-
-
Save qxj/c6731afeba882f00ea6b to your computer and use it in GitHub Desktop.
Add existed directory in hdfs into each partition of tables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# @(#) add_partition.sh Time-stamp: <Julian Qian 2015-06-08 17:10:46> | |
# Copyright 2015 Julian Qian | |
# Author: Julian Qian <[email protected]> | |
# Version: $Id: add_partition.sh,v 0.1 2015-06-08 17:08:46 jqian Exp $ | |
# | |
tables=(php_web_log ) | |
for tbl in ${tables[@]}; | |
do | |
for d in $(hadoop fs -ls /user/hive/wood/$tbl|grep -oE "ds=.+"); | |
do | |
day=${d:3:8} | |
echo "partition for $tbl/ds=$day ..." | |
for h in $(hadoop fs -ls /user/hive/wood/$tbl/$d|grep -oE "hr=.+"); | |
do | |
hour=${h:3:8} | |
echo "add partition for $tbl/ds=$day/hr=$hour ..." | |
#hive -e "ALTER TABLE db.$tbl ADD PARTITION(ds='$day',hr='$hour') LOCATION '/user/hive/wood/$tbl/ds=${day}/hr=${hour}'" | |
done | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment