获取hive表的最近一个分区
#!/bin/sh
table1='db_name.tbl_name'
v_partition=`hive -e "show partitions $table1" | grep "pt=*" | sort | tail -n 1`
last_partition=${v_partition:10:8}
echo ${last_partition}
判断hive表的分区是否存在
#!/bin/sh
incDay=`date -d "1 day ago" +%Y%m%d`
table1='db_name.tbl_name'
pt=$incDay
temp=`hive -e "show partitions $table1"`
echo $temp|grep -wq "$pt"
if [ $? -eq 0 ];then
echo "true"
else
echo "false"
fi