需求背景:
处理累积性表时候,我们导入当天的新增和变化,对于新增的数据,导入新的分区,
对于变化的数据,去更新历史的,而避免了全量更新
现在同样需要一个方案,对于dt的数据,如何对dwd->ads的有变化的dt进行重新计算
#!/bin/bash
db=paascloud
hive=/opt/cloudera/parcels/CDH-5.16.2-1.cdh5.16.2.p0.8/bin/hive
if [ $1 ];
then
do_date1=$1
else
echo "指定计算日期"
exit
fi
flag=`$hive -e "
use $db;
set hive.cli.print.header=false;
set HIVE_SKIP_SPARK_ASSEMBLY=true;
select
ct
from (
select
date_format(ordercreatetime, 'yyyy-MM-dd') as ct
from
ods_order
where
dt = '$1'
) t group by ct
;
"`
arr1=()
for i in $flag
do
if [[ $i == "20"* ]] && [[ ${#i} == 10 ]]
then
arr1+=($i)
fi
done
strA=$flag
strB="信息"
result=$(echo $strA | grep "${strB}")
if [[ "$result" != "" ]]
then
echo "$1"
else
#echo "$flag"
echo ${arr1[*]}
fi
使用
for i in `/root/bin/paascloud/get_changed_dt.sh $dt`
do
echo ===================执行变化的日期:$i ===========================
f $i
done