function wait_table()
{
database=$1
table_name=$2
table_partition=$3
if [ $# -ge 4 ]
then
((minute=$4*2))
else
minute=600
fi
set +e
for ((i=0;i<=$minute;i=i+1))
do
cnt=`hive -e "use $database;show partitions $table_name" | grep $table_partition |wc -l`
t=`date +"%F %T"`
#if [ "$cnt" = '1' ];
if [ $cnt -ge 1 ];
then
echo "$t Found partition $table_partition of table ${database}.$table_name ."
set -e
return 0
fi
if [ $minute -eq 0 ]
then
break
fi
echo "$t Waiting partition $table_partition of table ${database}.$table_name to be ready ..."
sleep 30
done
set -e
echo "$t No partition $table_partition of table ${database}.$table_name found."
return 1
}
等待hive上游数据公用函数
最新推荐文章于 2024-04-06 22:20:19 发布