Commit e408b967 by mengdongxing

Update tkdm_base_active_payment_info.sql

parent cab31be3
...@@ -7,25 +7,27 @@ set hive.merge.mapredfiles=true; ...@@ -7,25 +7,27 @@ set hive.merge.mapredfiles=true;
set hive.auto.convert.sortmerge.join=true; set hive.auto.convert.sortmerge.join=true;
insert overwrite table tkdm.tkdm_base_active_payment_info partition(ds='2017-02-25') insert overwrite table tkdm.tkdm_base_active_payment_info partition(ds='2017-02-25')
select x.deviceid, select /*+mapjoin(y)*/x.deviceid,
x.appid, x.appid,
x.cid, x.cid,
x.ins_date, x.first_ins_date,
x.last_ins_date,
x.category_id, x.category_id,
x.isgame, x.isgame,
x.platform, x.platform,
nvl(x.first_payment_ds,y.first_payment_ds) as first_payment_ds, nvl(x.first_payment_ds,y.first_payment_ds) as first_payment_ds,
nvl(y.last_payment_ds,x.amt_payment_last) as last_payment_ds, nvl(y.last_payment_ds,x.last_amt_payment) as last_payment_ds,
x.num_payment_cnt + y.num_payment_cnt as num_payment_cnt, x.num_payment_cnt + y.num_payment_cnt as num_payment_cnt,
x.num_payment_day + y.num_payment_day as num_payment_day, x.num_payment_day + y.num_payment_day as num_payment_day,
x.amt_payment +y.amt_payment as amt_payment, x.amt_payment +y.amt_payment as amt_payment,
nvl(y.amt_payment,x.amt_payment_last) as amt_payment_last nvl(y.amt_payment,x.last_amt_payment) as last_amt_payment
from from
(select nvl(a.deviceid,b.deviceid) as deviceid, (select nvl(a.deviceid,b.deviceid) as deviceid,
nvl(a.appid,b.appid) as appid, nvl(a.appid,b.appid) as appid,
nvl(b.cid,a.cid) as cid, nvl(b.cid,a.cid) as cid,
nvl(b.ins_date,a.ins_date) as ins_date, nvl(a.first_ins_date,b.ins_date) as first_ins_date,
nvl(b.ins_date,a.last_ins_date) as last_ins_date,
nvl(b.category_id,a.category_id) as category_id, nvl(b.category_id,a.category_id) as category_id,
nvl(b.isgame,a.isgame) as isgame, nvl(b.isgame,a.isgame) as isgame,
nvl(b.platform,a.platform) as platform, nvl(b.platform,a.platform) as platform,
...@@ -34,12 +36,13 @@ from ...@@ -34,12 +36,13 @@ from
nvl(a.num_payment_cnt,0) as num_payment_cnt, nvl(a.num_payment_cnt,0) as num_payment_cnt,
nvl(a.num_payment_day,0) as num_payment_day, nvl(a.num_payment_day,0) as num_payment_day,
nvl(a.amt_payment,0) amt_payment, nvl(a.amt_payment,0) amt_payment,
nvl(a.amt_payment_last,0) as amt_payment_last nvl(a.last_amt_payment,0) as last_amt_payment
from from
(select deviceid, (select deviceid,
appid, appid,
cid, cid,
ins_date, first_ins_date,
last_ins_date,
category_id, category_id,
isgame, isgame,
platform, platform,
...@@ -48,7 +51,7 @@ from ...@@ -48,7 +51,7 @@ from
num_payment_cnt, num_payment_cnt,
num_payment_day, num_payment_day,
amt_payment, amt_payment,
amt_payment_last last_amt_payment
from tkdm.tkdm_base_active_payment_info from tkdm.tkdm_base_active_payment_info
where ds=date_sub('2017-02-25',1) where ds=date_sub('2017-02-25',1)
) a ) a
...@@ -87,7 +90,8 @@ create EXTERNAL table tkdm_base_active_payment_info( ...@@ -87,7 +90,8 @@ create EXTERNAL table tkdm_base_active_payment_info(
appid string, appid string,
deviceid string, deviceid string,
cid int, cid int,
ins_date string, first_ins_date string,
last_ins_date string,
category_id int, category_id int,
isgame int, isgame int,
platform string, platform string,
...@@ -96,7 +100,7 @@ last_payment_ds string, ...@@ -96,7 +100,7 @@ last_payment_ds string,
num_payment_cnt int, num_payment_cnt int,
num_payment_day int, num_payment_day int,
amt_payment double, amt_payment double,
amt_payment_last double last_amt_payment double
) )
PARTITIONED BY (ds string) PARTITIONED BY (ds string)
clustered by (deviceid) sorted by(deviceid,appid) into 32 buckets clustered by (deviceid) sorted by(deviceid,appid) into 32 buckets
......
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