-- 日启动表 => DWS drop table t1; create table t1( id int, dt string ) row format delimited fields terminated by ','; load data local inpath '/data/lagoudw/data/t10.dat' into table t1;
-- 全量数据 => DWS drop table t2; create table t2( id int, dt string ) row format delimited fields terminated by ','; load data local inpath '/data/lagoudw/data/t2.dat' into table t2;
if [ -n "$1" ] then do_date=$1 else do_date=`date -d "-1 day" +%F` fi
sql=" insert into table dws.dws_member_add_day select t1.device_id, t1.uid, t1.app_v, t1.os_type, t1.language, t1.channel, t1.area, t1.brand, '$do_date' from dws.dws_member_start_day t1 left join dws.dws_member_add_day t2 on t1.device_id=t2.device_id where t1.dt='$do_date' and t2.device_id is null; "
hive -e "$sql"
创建ADS层表
1 2 3 4 5 6 7 8 9
use ADS;
drop table if exists ads.ads_new_member_cnt;
create table ads.ads_new_member_cnt ( `cnt` string ) partitioned by(dt string) row format delimited fields terminated by ',';
加载ADS层数据
创建script/member_active/ads_load_member_add.sh
#!/bin/bash
source /etc/profile
if [ -n "$1" ]
then
do_date=$1
else
do_date=`date -d "-1 day" +%F`
fi
sql="
insert overwrite table ads.ads_new_member_cnt partition (dt='$do_date')
select count(1)
from dws.dws_member_add_day
where dt = '$do_date'
"
hive -e "$sql"