#!/bin/bash
source /etc/profile
sleep 10
echo "v20180202"
data_date=`date -d "$today" +%Y%m%d --date="-1 day"`
function getPath()
{
sql_text="select s.LOCATION
from dbs d
inner join tbls t on d.DB_ID = t.DB_ID
inner join partitions p on t.TBL_ID = p.TBL_ID
inner join sds s on p.SD_ID = s.SD_ID
where d.name='${1}'
and t.TBL_NAME='${2}'
and p.PART_NAME='${3}'
;"
hdfs=`mysql -hsfbdp1mtstore-m.db.sfdc.com.cn -ucheck_user -psf123456 -Dsfbdp1mtstore -s -N -f -e "${sql_text}"`
echo ${hdfs}
}
function check_hdfs()
{
#通过元数据获取hdfs路径
fullPath=`getPath "$1" "$2" "$3"`
#检测分区是否已创建
if [ ! $fullPath ]; then
echo "#表$1.$2分区($3)不存在。"