1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#! /bin/bash
# # # # # # # # # # # # # # # # # # # # # #
# @file :merge_dmp.sh
# @author :liushuai
# @revision:2017-03-06 10:45
# @desc :3天前的M系统,dsp,ga数据整合到一起
# # # # # # # # # # # # # # # # # # # # # #
source ../prd_env.sh
LOG_TIME=$(date +%Y%m%d -d "-3 day $ScheduleTime")
year=${LOG_TIME:0:4}
month=${LOG_TIME:4:2}
day=${LOG_TIME:6:2}
hive_cmd "
use dev;
drop table tmp_dmp;
create table if not exists tmp_dmp
as
select distinct nvl(nvl(a.device_id,b.device_id),c.device_id) device_id,
nvl(nvl(a.device_type,b.device_type),c.id_type) device_type,
nvl(nvl(a.country ,b.country),c.country_code) country
from (
select device_id,device_type,country
from dwh.ods_ga_device_total
where year='${year}' and
month='${month}' and
day='${day}' and
device_id is not null
) a
FULL JOIN (
select device_id,device_type,country
from dwh.dm_profile_total
where type='dsp' and
year='${year}' and
month='${month}' and
day='${day}' and
device_id is not null
) b
on
a.device_id=b.device_id and a.device_type=b.device_type
Full JOIN (
select device_id,id_type,country_code
from dwh.ods_adn_device_total
where year='${year}' and
month='${month}' and
day='${day}' and
device_id is not null
) c
on
a.device_id=c.device_id and a.device_type=c.id_type;
"
if [ $? -ne 0 ];then
exit 255
fi