Commit 1e47cb9f by mengdongxing

Update tkdm_base_device_pay_info.sql

parent 5056198a
...@@ -6,29 +6,28 @@ set hive.optimize.bucketmapjoin = true; ...@@ -6,29 +6,28 @@ set hive.optimize.bucketmapjoin = true;
set hive.optimize.bucketmapjoin.sortedmerge = true; set hive.optimize.bucketmapjoin.sortedmerge = true;
set hive.merge.mapredfiles=true; set hive.merge.mapredfiles=true;
--insert overwrite table tkdm.tkdm_base_device_pay_info partition(ds='2017-02-24')
insert overwrite table tkdm.tkdm_base_device_pay_info partition(ds='2017-02-23')
select /*+mapjoin(a)*/ nvl(b.appid,a.appid) as appid, select /*+mapjoin(a)*/ nvl(b.appid,a.appid) as appid,
nvl(b.deviceid,a.deviceid) as deviceid, nvl(b.deviceid,a.deviceid) as deviceid,
nvl(b.first_payment_ds,'2017-02-23') as first_payment_ds, nvl(b.first_payment_ds,'2017-02-24') as first_payment_ds,
if(isnull(a.deviceid),'2017-02-23',nvl(b.last_payment_ds,'1970-01-01')) as last_payment_ds, if(isnull(a.deviceid),'2017-02-24',nvl(b.last_payment_ds,'1970-01-01')) as last_payment_ds,
nvl(b.num_payment_cnt,0)+nvl(a.num_payment_cnt,0) as num_payment_cnt, nvl(b.num_payment_cnt,0)+nvl(a.num_payment_cnt,0) as num_payment_cnt,
nvl(b.num_payment_day,0)+nvl(a.num_payment_day,0) as num_payment_day, nvl(b.num_payment_day,0)+nvl(a.num_payment_day,0) as num_payment_day,
round(nvl(b.amt_payment,0) + nvl(a.amt_payment,0),2) as amt_payment round(nvl(b.amt_payment,0) + nvl(a.amt_payment,0),2) as amt_payment
from from
(select appid, (select appid,
deviceid, deviceid,
round(sum(amount),2) as amt_payment, is_new,
count(1) as num_payment_cnt, amt_payment,
num_payment_cnt,
1 as num_payment_day 1 as num_payment_day
from tkio.tkio_mid_pay_day from tkdm.tkdm_data_payment_detial_day
where ds='2017-02-23' and where ds='2017-02-24' and
deviceid!='00000000-0000-0000-0000-000000000000' deviceid!='00000000-0000-0000-0000-000000000000'
and deviceid!='' and deviceid!='0' and deviceid!='' and deviceid!='0'
group by appid,deviceid
distribute by appid ,deviceid
) a ) a
join full join
(select appid, (select appid,
deviceid, deviceid,
...@@ -38,13 +37,14 @@ from ...@@ -38,13 +37,14 @@ from
num_payment_day, num_payment_day,
amt_payment amt_payment
from tkdm.tkdm_base_device_pay_info from tkdm.tkdm_base_device_pay_info
where ds= date_sub('2017-02-23',1) where ds= date_sub('2017-02-24',1)
) b on a.appid=b.appid and a.deviceid=b.deviceid ) b on a.appid=b.appid and a.deviceid=b.deviceid
use tkdm; use tkdm;
...@@ -64,4 +64,3 @@ FIELDS TERMINATED BY '\t' ...@@ -64,4 +64,3 @@ FIELDS TERMINATED BY '\t'
STORED AS ORC STORED AS ORC
location 's3://reyuntkio/warehouse/tkio/tkdm.db/tkdm_base_device_pay_info' location 's3://reyuntkio/warehouse/tkio/tkdm.db/tkdm_base_device_pay_info'
; ;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment