Commit 36e8585f by mengdongxing

Update tkdm_output_active_app_std_week.sql

parent 5bccc9e5
...@@ -3,18 +3,25 @@ CREATE TEMPORARY FUNCTION bootstrapmedian AS 'com.reyun.hive.udaf.BootStrap'; ...@@ -3,18 +3,25 @@ CREATE TEMPORARY FUNCTION bootstrapmedian AS 'com.reyun.hive.udaf.BootStrap';
insert overwrite table tkdm.tkdm_output_active_app_std_week partition(ds='2017-02-22') insert overwrite table tkdm.tkdm_output_active_app_std_week partition(ds='2017-02-22')
select /*+ mapjoin(x)*/ x.appid, select /*+ mapjoin(x)*/ x.appid,
'2017-02-22' as week_dt,
x.category_id, x.category_id,
x.isgame, x.isgame,
nvl(y.avg_ins_rate,-1) as avg_ins_rate, nvl(y.avg_ins_rate,-1) as avg_ins_rate,
nvl(y.approx_med_ins_rate,-1) as approx_med_ins_rate, nvl(y.approx_med_ins_rate,-1) as approx_med_ins_rate,
nvl(y.bootstarp_med_ins_rate,-1) as bootstarp_med_ins_rate nvl(y.bootstarp_med_ins_rate,-1) as bootstarp_med_ins_rate
from from
(select appid,category_id,isgame
from tkio_v2.tkio_dp_app_info
where ds='2017-02-28'
) as x
left join
(select category_id, (select category_id,
isgame, isgame,
round(avg(ins_rate), 4) avg_ins_rate, round(avg(ins_rate), 4) avg_ins_rate,
round(percentile_approx(ins_rate,0.5),4) approx_med_ins_rate, round(percentile_approx(ins_rate,0.5),4) approx_med_ins_rate,
round(bootstrapmedian(ins_rate),4) bootstarp_med_ins_rate round(bootstrapmedian(ins_rate),4) bootstarp_med_ins_rate
from ( from (
...@@ -28,20 +35,14 @@ from ...@@ -28,20 +35,14 @@ from
group by appid,category_id,isgame,ds group by appid,category_id,isgame,ds
) as tt ) as tt
group by category_id, isgame group by category_id, isgame
) y ) y on x.category_id=y.category_id and x.isgame=y.isgame
left join
(select appid,category_id,isgame
from tkio_v2.tkio_dp_app_info
where ds='2017-02-28'
) as x on x.category_id=y.category_id and x.isgame=y.isgame
create EXTERNAL table tkdm_output_active_app_std_week( create EXTERNAL table tkdm_output_active_app_std_week(
appid string, appid string,
week_dt string,
category_id int, category_id int,
isgame int, isgame int,
avg_ins_rate double, avg_ins_rate double,
...@@ -52,4 +53,4 @@ PARTITIONED BY (ds string) ...@@ -52,4 +53,4 @@ PARTITIONED BY (ds string)
ROW FORMAT DELIMITED ROW FORMAT DELIMITED
FIELDS TERMINATED BY '\t' FIELDS TERMINATED BY '\t'
location 's3://reyuntkio/warehouse/tkio/tkdm.db/tkdm_output_active_app_std_week' location 's3://reyuntkio/warehouse/tkio/tkdm.db/tkdm_output_active_app_std_week'
; ;
\ No newline at end of file
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