#!/usr/bin/env bash

# alter table dev.fe_event_core add if not exists partition(`day`='20190601',`hour`='18') location 's3://mob-emr-test/shun.yao/dsp_c_log_res/fe_event_core/20190601/18';

days="01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23"
# days="01"
hours="00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23"
# hours="00"
# hh="00 01 02 03 04 05 06 07 08 09"
# minute="00 15 30 45"

for day in ${days}
do
    for hour in ${hours}
    do
        # sql="alter table dev.fe_event_core add if not exists partition(\`day\`='201906${day}',\`hour\`='${hour}') location 's3://mob-emr-test/shun.yao/dsp_c_log_res/fe_event_core/201906${day}/${hour}';"
        sql="alter table dev.fe_event_error add if not exists partition(\`day\`='201906${day}',\`hour\`='${hour}') location 's3://mob-emr-test/shun.yao/dsp_c_log_res/fe_event_error/201906${day}/${hour}';"
        echo "${sql}"
        # hive -e "${sql}"
        if [[ $? -ne 0 ]];then
            exit 255
        fi
     done
done