Commit 5cd859a7 authored by 赵建伟's avatar 赵建伟

Merge branch 'weiyimin' into 'master'

Weiyimin

See merge request zhaojianwei/bi-report!12
parents 2a1cb0de 26739b20
demo=示例程序-demo
demo_bak=示例程序-demo_bak
demo_param=带参数的示例程序
demo_java=JAVA实例程序
meigou-detail-page=美购详情页
meigou-detail-page-dispense-pv=美购详情页分发pv
meigou-detail-page-dispense-uv=美购详情页分发uv
meigou-detail-page-source-pv=美购详情页来源pv
meigou-detail-page-source-uv=美购详情页来源uv
daily_content_data=内容日报-新
search_click_path=分搜索入口的搜索框点击数据
search_result_click_rate=分搜索词转化率数据
search_input_type=分搜索方式近7天数据
daily_recommend_strategy=首页推荐策略日报
#step3.job
type=command
dependencies=step2
command=sh /home/bi/bi-report/lib/shell/waitsuccess.sh hive pm tl_pm_content_d
\ No newline at end of file
#step4.job
type=command
dependencies=step3
command=curl -X GET http://localhost:8553/api/report/sendEmail/liudi@igengmei.com,wangxin@igengmei.com,malinxi@igengmei.com,dengguangyu@igengmei.com/weiyimin@igengmei.com,zhaojianwei@igengmei.com,zhaofei@igengmei.com,yindanlei@igengmei.com/daily_content_data
\ No newline at end of file
#step1_6.job
type=command
command=sh /home/bi/bi-report/lib/shell/waitsuccess.sh hive online tl_hdfs_doctor_view
\ No newline at end of file
#step1_8.job
type=command
command=sh /home/bi/bi-report/lib/shell/waitsuccess.sh hive online ml_user_history_detail
\ No newline at end of file
#step1_9.job
type=command
command=sh /home/bi/bi-report/lib/shell/waitsuccess.sh hive online ml_device_history_detail
\ No newline at end of file
#step2.job
type=command
dependencies=step1_1,step1_2,step1_3,step1_4,step1_5,step1_6,step1_7,step1_8,step1_9
command=/home/bi/bi-report/shells/daily_recommend_strategy/daily_recommend_strategy.sh
\ No newline at end of file
#step3.job
type=command
dependencies=step2
command=sh /home/bi/bi-report/lib/shell/waitsuccess.sh hive pm tl_pm_recommend_strategy_d
\ No newline at end of file
#step4.job
type=command
dependencies=step3
command=curl -X GET http://localhost:8553/api/report/sendEmail/weiyimin@igengmei.com/zhaojianwei@igengmei.com/daily_recommend_strategy
\ No newline at end of file
#step.job
type=command
command=/home/bi/bi-report/lib/shell/hive.sh demo
\ No newline at end of file
#step2.job
type=command
dependencies=step1_1,step1_2
command=curl -X GET http://localhost:8553/api/report/execSql?name=search_related_insert
\ No newline at end of file
#step3.job
type=command
dependencies=step2
command=sh /home/bi/bi-report/lib/shell/waitsuccess.sh hive pm tl_pm_search_click_path_d
\ No newline at end of file
#step4.job
type=command
dependencies=step3
command=curl -X GET http://localhost:8553/api/report/sendEmail/weiyimin@igengmei.com/search_related
\ No newline at end of file
daily_content_data=内容日报
\ No newline at end of file
--***************************************************************
--*脚本名称: create_pm_c_op_co_content_dimen_d.sql
--*脚本名称:
--*功能: 内容日报
--*业务名称: pm
--*输入数据:
--*作者: weiyimin@igengmei.com
--*更新时间: 2020-5-25 11:00
--*更新时间:
--***************************************************************
--设置全局变量&UDF
......
#step2.job
type=command
dependencies=step1_1,step1_2,step1_3,step1_4,step1_5,step1_6,step1_7,step1_8,step1_9,step1_10,step1_11,step1_12,step1_13
command=curl -X GET http://localhost:8553/api/report/execSql?name=daily_content_data_insert
\ No newline at end of file
command=/home/bi/bi-report/lib/shell/hive daily_content_data
\ No newline at end of file
#step3.job
type=command
dependencies=step2
command=curl -X GET http://localhost:8553/api/report/email/daily_content_data/liudi@igengmei.com,wangxin@igengmei.com,malinxi@igengmei.com,dengguangyu@igengmei.com/weiyimin@igengmei.com,zhaojianwei@igengmei.com,zhaofei@igengmei.com,yindanlei@igengmei.com
\ No newline at end of file
--***************************************************************
--*脚本名称: create_pm_c_op_co_content_dimen_d.sql
--*功能: 内容日报
--*脚本名称:
--*功能: 首页推荐策略日报
--*业务名称: pm
--*输入数据:
--*作者: weiyimin@igengmei.com
--*更新时间: 2020-5-25 11:00
--*更新时间:
--***************************************************************
--设置全局变量&UDF
......
#step3.job
type=command
dependencies=step2
command=curl -X GET http://localhost:8553/api/report/email/daily_recommend_strategy/zhaojianwei@igengmei.com/jianweizhao@yeah.net
\ No newline at end of file
command=curl -X GET http://localhost:8553/api/report/email/daily_recommend_strategy/liudi@igengmei.com,wangxin@igengmei.com,liweirui@igengmei.com,duanyingrong@igengmei.com,xuepengfei@igengmei.com,dengguangyu@igengmei.com,zhaowei@igengmei.com,songke@igengmei.com/zhaofei@igengmei.com,yindanlei@igengmei.com,weiyimin@igengmei.com,zhaojianwei@igengmei.com
\ No newline at end of file
meigou_detail_page=美购详情页来源与分发
meigou_detail_page_dispense_pv=美购详情页分发pv
meigou_detail_page_dispense_uv=美购详情页分发uv
meigou_detail_page_source_pv=美购详情页来源pv
meigou_detail_page_source_uv=美购详情页来源uv
\ No newline at end of file
#step1_1.job
type=command
command=sh /home/bi/bi-report/lib/shell/waitsuccess.sh hive online ml_device_day_active_status
\ No newline at end of file
command=sh /home/bi/bi-report/lib/shell/waitsuccess.sh hive online bl_hdfs_maidian_updates
\ No newline at end of file
#step1_2.job
type=command
command=sh /home/bi/bi-report/lib/shell/waitsuccess.sh hive online ml_community_precise_exposure_detail
\ No newline at end of file
command=sh /home/bi/bi-report/lib/shell/waitsuccess.sh hive online ml_device_day_active_status
\ No newline at end of file
#step1_7.job
#step1_3.job
type=command
command=sh /home/bi/bi-report/lib/shell/waitsuccess.sh hive ml ml_c_ct_ui_user_dimen_d
\ No newline at end of file
command=sh /home/bi/bi-report/lib/shell/waitsuccess.sh hive ml ml_d_ct_dv_devicespam_d
\ No newline at end of file
#step2.job
type=command
dependencies=step1_1,step1_2,step1_3
command=curl -X GET http://localhost:8553/api/report/email/meigou_detail_page/liudi@igengmei.com,wangxin@igengmei.com,zhaofei@igengmei.com/weiyimin@igengmei.com,yindanlei@igengmei.com,zhaojianwei@igengmei.com
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
search_click_path=分搜索入口的搜索框点击数据
search_input_type=分搜索方式近7天数据
search_result_click_rate=分搜索词转化率数据
search_related=分搜索方式及搜索词日报
\ No newline at end of file
--***************************************************************
--*脚本名称: create_pm_c_op_co_content_dimen_d.sql
--*功能: 内容日报
--*脚本名称:
--*功能: 分搜索入口搜索日报
--*业务名称: pm
--*输入数据:
--*作者: weiyimin@igengmei.com
--*更新时间: 2020-5-25 11:00
--*更新时间:
--***************************************************************
--设置全局变量&UDF
......
--***************************************************************
--*脚本名称: create_pm_c_op_co_content_dimen_d.sql
--*功能: 内容日报
--*脚本名称:
--*功能: 分搜索方式日报
--*业务名称: pm
--*输入数据:
--*作者: weiyimin@igengmei.com
--*更新时间: 2020-5-25 11:00
--*更新时间:
--***************************************************************
--设置全局变量&UDF
......
--***************************************************************
--*脚本名称: create_pm_c_op_co_content_dimen_d.sql
--*功能: 内容日报
--*脚本名称:
--*功能: 分搜索关键词转化日报
--*业务名称: pm
--*输入数据:
--*作者: weiyimin@igengmei.com
--*更新时间: 2020-5-25 11:00
--*更新时间:
--***************************************************************
--设置全局变量&UDF
......
INSERT OVERWRITE TABLE pm.tl_pm_search_result_click_rate_d PARTITION (PARTITION_DAY = #partition_day)
SET mapreduce.job.queuename=data;
SET mapreduce.map.memory.mb=8192;
SET mapreduce.map.java.opts=-Xmx8000m;
SET mapreduce.reduce.memory.mb=8192;
SET mapreduce.reduce.java.opts=-Xmx8000m;
set hive.auto.convert.join=true;
SET mapred.reduce.tasks=20;
SET role admin;
INSERT OVERWRITE TABLE pm.tl_pm_search_click_path_d PARTITION (PARTITION_DAY = ${partition_day})
SELECT day_id as day_id
,device_os_type as device_os_type
,active_type as active_type
,v.search_entrance as search_entrance
,sum(search_pv) as click_search_pv
,sum(search_uv) as click_search_uv
FROM
(
SELECT day_id,device_os_type,active_type,array(search_entrance,'合计') as search_entrance
,search_pv,search_uv
FROM
(
SELECT t1.partition_date as day_id
,t1.device_os_type
,t1.active_type
,case when action='on_click_navbar_search' and page_name='home' then '首页搜索框'
when action='on_click_navbar_search' and page_name='welfare_home' then '美购首页搜索框'
when action='on_click_navbar_search' and page_name='category' then '品类聚合页搜索框'
when action='on_click_navbar_search' and page_name='welfare_list' and referrer_link ='["home","category"]' then '来自品类聚合的美购列表页搜索框'
when action='on_click_navbar_search' and page_name='welfare_list' and referrer_link ='["welfare_home"]' then '来自美购首页的美购列表页搜索框'
when action in ('do_search','on_click_navbar_search')
and page_name in ('diary_detail','topic_detail','post_detail','user_post_detail'
,'doctor_post_detail','question_detail','answer_detail','question_answer_detail') then '内容详情页搜索框'
when action ='详情页高亮词' then '详情页高亮词搜索'
when action='大家都在看' then '首页feed大家都在看'
when action='热搜词' then '美购首页热搜词' else null end as search_entrance
,count(cl_id) as search_pv
,count(distinct cl_id) as search_uv
FROM
(
SELECT partition_date,device_os_type
,case WHEN active_type = '4' THEN '老活跃设备'
WHEN active_type in ('1','2') then '新增设备' END as active_type
,device_id
FROM online.ml_device_day_active_status
where partition_date = regexp_replace(DATE_SUB(current_date,1) ,'-','')
AND active_type in ('1','2','4')
and first_channel_source_type not in ('yqxiu1','yqxiu2','yqxiu3','yqxiu4','yqxiu5','mxyc1','mxyc2','mxyc3'
,'wanpu','jinshan','jx','maimai','zhuoyi','huatian','suopingjingling','mocha','mizhe','meika','lamabang'
,'js-az1','js-az2','js-az3','js-az4','js-az5','jfq-az1','jfq-az2','jfq-az3','jfq-az4','jfq-az5','toufang1'
,'toufang2','toufang3','toufang4','toufang5','toufang6','TF-toufang1','TF-toufang2','TF-toufang3','TF-toufang4'
,'TF-toufang5','tf-toufang1','tf-toufang2','tf-toufang3','tf-toufang4','tf-toufang5','benzhan','promotion_aso100'
,'promotion_qianka','promotion_xiaoyu','promotion_dianru','promotion_malioaso','promotion_malioaso-shequ'
,'promotion_shike','promotion_julang_jl03','promotion_zuimei')
AND first_channel_source_type not like 'promotion\_jf\_%'
)t1
join
(
SELECT partition_date,cl_id,page_name,action,params['referrer_link'] as referrer_link
FROM online.bl_hdfs_maidian_updates
where partition_date = regexp_replace(DATE_SUB(current_date,1) ,'-','')
and action in ('do_search','on_click_navbar_search')
union all
SELECT partition_date,cl_id,null as page_name,'大家都在看' as action, null as referrer_link
FROM online.bl_hdfs_maidian_updates
where partition_date = regexp_replace(DATE_SUB(current_date,1) ,'-','')
AND action = 'on_click_card'
AND params['in_page_pos']='猜你喜欢'
AND params['tab_name']='精选'
AND params['card_type']='search_word'
--AND page_name='home' android的page_name为空
union all
SELECT partition_date,cl_id,page_name,'热搜词' as action, null as referrer_link
FROM online.bl_hdfs_maidian_updates
where partition_date = regexp_replace(DATE_SUB(current_date,1) ,'-','')
AND action = 'on_click_card'
AND page_name='welfare_home'
AND params['card_type'] ='search_word'
AND params['in_page_pos']='大家都在搜'
union all
select partition_date,cl_id,null as page_name,'详情页高亮词' as action,null as referrer_link
from online.bl_hdfs_maidian_updates
where partition_date = regexp_replace(DATE_SUB(current_date,1) ,'-','')
and action='on_click_card'
and params['card_type']='highlight_word'
)t2
on t1.partition_date=t2.partition_date and t1.device_id=t2.cl_id
group by t1.partition_date
,t1.device_os_type
,t1.active_type
,case when action='on_click_navbar_search' and page_name='home' then '首页搜索框'
when action='on_click_navbar_search' and page_name='welfare_home' then '美购首页搜索框'
when action='on_click_navbar_search' and page_name='category' then '品类聚合页搜索框'
when action='on_click_navbar_search' and page_name='welfare_list' and referrer_link ='["home","category"]' then '来自品类聚合的美购列表页搜索框'
when action='on_click_navbar_search' and page_name='welfare_list' and referrer_link ='["welfare_home"]' then '来自美购首页的美购列表页搜索框'
when action in ('do_search','on_click_navbar_search')
and page_name in ('diary_detail','topic_detail','post_detail','user_post_detail'
,'doctor_post_detail','question_detail','answer_detail','question_answer_detail') then '内容详情页搜索框'
when action ='详情页高亮词' then '详情页高亮词搜索'
when action='大家都在看' then '首页feed大家都在看'
when action='热搜词' then '美购首页热搜词' else null end
having search_entrance is not null
)t
)n
LATERAL VIEW explode(n.search_entrance) v AS search_entrance
group by day_id,device_os_type,active_type,v.search_entrance;
INSERT OVERWRITE TABLE pm.tl_pm_search_input_type_d PARTITION (PARTITION_DAY = ${partition_day})
SELECT partition_date as day_id
,t1.query
,t2.input_type
,sum(t1.all_search_pv) as search_pv
FROM
(
SELECT
partition_date
,query
,array(case when input_type in ('联想','聚合模块') then 'sug点击' else input_type end,'全部') as input_type
,count(click.cl_id) as all_search_pv
,count(distinct click.cl_id) as all_search_uv
FROM
(
SELECT cl_id
,partition_date
,case when params['input_type'] in ('热门','related_search') then '发现' else params['input_type'] end as input_type
,params['query'] as query
FROM online.bl_hdfs_maidian_updates
WHERE partition_date = regexp_replace(DATE_SUB(current_date,1) ,'-','')
AND action in ('do_search','search_result_click_search')
union all
SELECT cl_id
,partition_date
,'首页精选大家都在看' as input_type
,params['card_name'] as query
FROM online.bl_hdfs_maidian_updates
WHERE partition_date = regexp_replace(DATE_SUB(current_date,1) ,'-','')
AND action = 'on_click_card'
AND params['in_page_pos']='猜你喜欢'
AND params['tab_name']='精选'
AND params['card_type']='search_word'
--AND page_name='home' android的page_name为空
union all
SELECT cl_id
,partition_date
,'美购首页热搜词' as input_type
,params['card_name'] as query
FROM online.bl_hdfs_maidian_updates
WHERE partition_date = regexp_replace(DATE_SUB(current_date,1) ,'-','')
AND action = 'on_click_card'
AND page_name='welfare_home'
AND params['card_type'] ='search_word'
AND params['in_page_pos']='大家都在搜'
union all
select cl_id
,partition_date
,'详情页高亮词' as input_type
,params['card_name'] as query
from online.bl_hdfs_maidian_updates
where partition_date = regexp_replace(DATE_SUB(current_date,1) ,'-','')
and int(split(app_version,'\\.')[1]) >= 27
and action='on_click_card'
and params['card_type']='highlight_word'
)click
JOIN
(
SELECT device_id
from online.ml_device_history_detail
WHERE partition_date = regexp_replace(DATE_SUB(current_date,1) ,'-','')
and first_channel_source_type not in ('yqxiu1','yqxiu2','yqxiu3','yqxiu4','yqxiu5','mxyc1','mxyc2','mxyc3'
,'wanpu','jinshan','jx','maimai','zhuoyi','huatian','suopingjingling','mocha','mizhe','meika','lamabang'
,'js-az1','js-az2','js-az3','js-az4','js-az5','jfq-az1','jfq-az2','jfq-az3','jfq-az4','jfq-az5','toufang1'
,'toufang2','toufang3','toufang4','toufang5','toufang6','TF-toufang1','TF-toufang2','TF-toufang3','TF-toufang4'
,'TF-toufang5','tf-toufang1','tf-toufang2','tf-toufang3','tf-toufang4','tf-toufang5','benzhan','promotion_aso100'
,'promotion_qianka','promotion_xiaoyu','promotion_dianru','promotion_malioaso','promotion_malioaso-shequ'
,'promotion_shike','promotion_julang_jl03','promotion_zuimei')
AND first_channel_source_type not like 'promotion\_jf\_%'
)dev_channel
on dev_channel.device_id = click.cl_id
GROUP BY partition_date,query,case when input_type in ('联想','聚合模块') then 'sug点击' else input_type end
)t1
LATERAL VIEW explode(t1.input_type) t2 AS input_type
GROUP BY t1.partition_date,t1.query,t2.input_type;
INSERT OVERWRITE TABLE pm.tl_pm_search_result_click_rate_d PARTITION (PARTITION_DAY = ${partition_day})
--搜索关键词日报,取近7天数据,每天取关键词搜索量前500
......@@ -119,7 +320,6 @@ from
where rank<=300
)t1
left join
--综合、美购、日记页面浏览pv
(
......@@ -430,11 +630,4 @@ left join
on t1.partition_date=t2.partition_date
and t1.query=t2.query
order by day_id desc,search_pv desc,query
order by day_id desc,search_pv desc,query;
\ No newline at end of file
#step1_2.job
type=command
command=sh /home/bi/bi-report/lib/shell/waitsuccess.sh hive online bl_hdfs_maidian_updates
\ No newline at end of file
command=sh /home/bi/bi-report/lib/shell/waitsuccess.sh hive online ml_device_history_detail
\ No newline at end of file
#step1_5.job
type=command
command=sh /home/bi/bi-report/lib/shell/waitsuccess.sh hive online ml_user_updates
\ No newline at end of file
command=sh /home/bi/bi-report/lib/shell/waitsuccess.sh hive online ml_community_precise_exposure_detail
\ No newline at end of file
#step2.job
type=command
dependencies=step1_1,step1_2,step1_3,step1_4,step1_5
command=/home/bi/bi-report/lib/shell/hive search_related
\ No newline at end of file
#step3.job
type=command
dependencies=step2
command=curl -X GET http://localhost:8553/api/report/email/search_related/liudi@igengmei.com,wangxin@igengmei.com,malinxi@igengmei.com,duanyingrong@igengmei.com,dengguangyu@igengmei.com/zhaofei@igengmei.com,yindanlei@igengmei.com,weiyimin@igengmei.com,zhaojianwei@igengmei.com
\ No newline at end of file
--近7天搜索方式的搜索量
SELECT regexp_replace(DATE_SUB(current_date,1) ,'-','') AS `日期`,
T4.QUERY AS `搜索词`,
T4.INPUT_TYPE AS `搜索类型`,
T4.SEARCH_PV AS `搜索量`
FROM
(SELECT T3.*
FROM (SELECT T2.*,
SUM(SEARCH_PV_ALL) OVER(PARTITION BY T2.QUERY) SEARCH_PV_SUM,
ROW_NUMBER() OVER(PARTITION BY T2.QUERY ORDER BY SEARCH_PV DESC) SEARCH_PV_GROUP_SUM,
DENSE_RANK() OVER(ORDER BY SUM(SEARCH_PV_ALL) OVER(PARTITION BY T2.QUERY) DESC,T2.QUERY) SEARCH_PV_GROUP
FROM (SELECT T1.*,
CASE
WHEN INPUT_TYPE = '全部' THEN
0
ELSE
1
END INPUT_TYPE_RANK,
CASE
WHEN INPUT_TYPE = '全部' THEN
SEARCH_PV
ELSE
0
END SEARCH_PV_ALL
FROM (SELECT QUERY,INPUT_TYPE,SUM(SEARCH_PV) AS SEARCH_PV
FROM PM.TL_PM_SEARCH_INPUT_TYPE_D T
WHERE T.PARTITION_DAY >= regexp_replace(DATE_SUB(current_date,7) ,'-','')
AND T.PARTITION_DAY<regexp_replace((current_date),'-','')
AND T.DAY_ID >= regexp_replace(DATE_SUB(current_date,7) ,'-','')
AND T.DAY_ID<regexp_replace((current_date),'-','')
GROUP BY T.QUERY,T.INPUT_TYPE) T1) T2)T3
WHERE SEARCH_PV_GROUP<=300
ORDER BY T3.SEARCH_PV_SUM DESC,
T3.QUERY,
T3.INPUT_TYPE_RANK,
T3.SEARCH_PV_GROUP_SUM)T4
\ No newline at end of file
......@@ -5,17 +5,17 @@ SELECT
,query AS `关键词`
,search_pv AS `搜索量`
,search_uv AS `搜索uv`
,NVL(case when NVL(t2.page_more_pv,0)>0 then concat(round(t2.more_click_pv*100/t2.page_more_pv,2) ,'%') else 0 end, 0) as `搜索综合结果页内容卡片点击PV/搜索综合结果页浏览pv`
,NVL(case when NVL(t2.page_more_pv,0)>0 then concat(round(t2.more_click_10_pv*100/t2.page_more_pv,2) ,'%') else 0 end,0) as `搜索综合结果页前10内容卡片点击PV/搜索综合结果页浏览pv`
,NVL(case when NVL(t2.page_more_pv,0)>0 then concat(round(t2.more_click_5_diary_pv*100/t2.page_more_pv,2),'%') else 0 end,0) as `搜索综合结果页前5日记卡片点击PV/搜索综合结果页浏览pv`
,NVL(case when NVL(t2.page_more_pv,0)>0 then concat(round(t2.more_click_5_answer_pv*100/t2.page_more_pv,2),'%') else 0 end,0) as `搜索综合结果页前5问答卡片点击PV/搜索综合结果页浏览pv`
,NVL(case when NVL(t2.page_more_pv,0)>0 then concat(round(t2.more_click_5_topic_pv*100/t2.page_more_pv,2),'%') else 0 end,0) as `搜索综合结果页前5帖子卡片点击PV/搜索综合结果页浏览pv`
,NVL(case when NVL(t2.page_wel_pv,0)>0 then concat(round(t2.wel_click_pv*100/t2.page_wel_pv,2),'%') else 0 end,0) as `搜索美购结果页卡片点击PV/搜索美购结果页pv`
,NVL(case when NVL(t2.page_wel_pv,0)>0 then concat(round(t2.wel_click_10_pv*100/t2.page_wel_pv,2),'%') else 0 end,0) as `搜索美购结果页前10卡片点击PV/搜索美购结果页pv`
,NVL(case when NVL(t2.page_wel_pv,0)>0 then concat(round(t2.wel_click_5_pv*100/t2.page_wel_pv,2),'%') else 0 end,0) as `搜索美购结果页前5卡片点击PV/搜索美购结果页pv`
,NVL(case when NVL(t2.page_diary_pv,0)>0 then concat(round(t2.diary_click_pv*100/t2.page_diary_pv,2),'%') else 0 end,0) as `搜索日记结果页卡片点击PV/搜索日记结果页pv`
,NVL(case when NVL(t2.page_diary_pv,0)>0 then concat(round(t2.diary_click_10_pv*100/t2.page_diary_pv,2),'%') else 0 end,0) as `搜索日记结果页前10卡片点击PV/搜索日记结果页pv`
,NVL(case when NVL(t2.page_diary_pv,0)>0 then concat(round(t2.diary_click_5_pv*100/t2.page_diary_pv,2),'%') else 0 end,0) as `搜索日记结果页前5卡片点击PV/搜索日记结果页pv`
,NVL(case when NVL(page_more_pv,0)>0 then concat(round(more_click_pv*100/page_more_pv,2) ,'%') else 0 end, 0) as `搜索综合结果页内容卡片点击PV/搜索综合结果页浏览pv`
,NVL(case when NVL(page_more_pv,0)>0 then concat(round(more_click_10_pv*100/page_more_pv,2) ,'%') else 0 end,0) as `搜索综合结果页前10内容卡片点击PV/搜索综合结果页浏览pv`
,NVL(case when NVL(page_more_pv,0)>0 then concat(round(more_click_5_diary_pv*100/page_more_pv,2),'%') else 0 end,0) as `搜索综合结果页前5日记卡片点击PV/搜索综合结果页浏览pv`
,NVL(case when NVL(page_more_pv,0)>0 then concat(round(more_click_5_answer_pv*100/page_more_pv,2),'%') else 0 end,0) as `搜索综合结果页前5问答卡片点击PV/搜索综合结果页浏览pv`
,NVL(case when NVL(page_more_pv,0)>0 then concat(round(more_click_5_topic_pv*100/page_more_pv,2),'%') else 0 end,0) as `搜索综合结果页前5帖子卡片点击PV/搜索综合结果页浏览pv`
,NVL(case when NVL(page_wel_pv,0)>0 then concat(round(wel_click_pv*100/page_wel_pv,2),'%') else 0 end,0) as `搜索美购结果页卡片点击PV/搜索美购结果页pv`
,NVL(case when NVL(page_wel_pv,0)>0 then concat(round(wel_click_10_pv*100/page_wel_pv,2),'%') else 0 end,0) as `搜索美购结果页前10卡片点击PV/搜索美购结果页pv`
,NVL(case when NVL(page_wel_pv,0)>0 then concat(round(wel_click_5_pv*100/page_wel_pv,2),'%') else 0 end,0) as `搜索美购结果页前5卡片点击PV/搜索美购结果页pv`
,NVL(case when NVL(page_diary_pv,0)>0 then concat(round(diary_click_pv*100/page_diary_pv,2),'%') else 0 end,0) as `搜索日记结果页卡片点击PV/搜索日记结果页pv`
,NVL(case when NVL(page_diary_pv,0)>0 then concat(round(diary_click_10_pv*100/page_diary_pv,2),'%') else 0 end,0) as `搜索日记结果页前10卡片点击PV/搜索日记结果页pv`
,NVL(case when NVL(page_diary_pv,0)>0 then concat(round(diary_click_5_pv*100/page_diary_pv,2),'%') else 0 end,0) as `搜索日记结果页前5卡片点击PV/搜索日记结果页pv`
,search_more_pv AS `综合tab下的搜索的点击pv`
,page_more_pv AS `搜索综合结果页浏览PV`
,more_click_pv AS `搜索综合结果页内容卡片点击PV`
......@@ -36,4 +36,6 @@ SELECT
FROM pm.tl_pm_search_result_click_rate_d
WHERE partition_day>='20200619' and partition_day<=regexp_replace(DATE_SUB(current_date,1) ,'-','')
and day_id>=regexp_replace(DATE_SUB(current_date,7) ,'-','')
and day_id<=regexp_replace(DATE_SUB(current_date,1) ,'-','')
order by `日期` desc,`搜索量` desc,`关键词`
SELECT
day_id as `日期`,
device_os_type as `设备类型`,
active_type as `活跃类型`,
card_content_type as `卡片类型`,
recommend_type as `推荐类型`,
home_ctr as `首页卡片点击PV/首页卡片精准曝光PV`,
second_rate as `来自首页推荐内容卡片的的总商业二跳pv/首页卡片精准曝光PV`,
first_rate as `来自首页推荐内容卡片的的总商业二跳pv/首页卡片点击PV`,
card_click as `首页卡片点击PV`,
card_exposure as `首页卡片精准曝光PV`,
total_second_click as `来自I的总商业二跳pv(包含M列到T列)`,
avg_page_stay as `来自I的单PV平均浏览时长`,
navbar_search as `来自I的搜索框+搜索按钮点击PV`,
highlight_word as `来自I的文内搜索点击PV`,
self_welfare_card as `来自I的商品卡片点击PV`,
recommend_welfare_card as `来自I的推荐商品+查看全部商品点击pv`,
recommend_content_card as `来自I的推荐内容点击pv`,
'未配置' as `来自I的推荐专题点击pv`,
'未上线' as `来自I的转诊点击pv`,
'未上线' as `来自I的视频面诊点击pv`
FROM pm.tl_pm_recommend_strategy_d
WHERE partition_day>='20200619' and partition_day<=regexp_replace(DATE_SUB(current_date,1) ,'-','')
order by `日期` desc ,`设备类型`,`活跃类型`,`卡片类型`,`推荐类型`
SET mapreduce.job.queuename=data;
SET mapreduce.map.memory.mb=8192;
SET mapreduce.map.java.opts=-Xmx8000m;
SET mapreduce.reduce.memory.mb=8192;
SET mapreduce.reduce.java.opts=-Xmx8000m;
set hive.auto.convert.join=true;
SET mapred.reduce.tasks=20;
SET role admin;
INSERT OVERWRITE TABLE pm.tl_pm_search_click_path_d PARTITION (PARTITION_DAY = ${partition_day})
SELECT day_id as day_id
,device_os_type as device_os_type
,active_type as active_type
,v.search_entrance as search_entrance
,sum(search_pv) as click_search_pv
,sum(search_uv) as click_search_uv
FROM
(
SELECT day_id,device_os_type,active_type,array(search_entrance,'合计') as search_entrance
,search_pv,search_uv
FROM
(
SELECT t1.partition_date as day_id
,t1.device_os_type
,t1.active_type
,case when action='on_click_navbar_search' and page_name='home' then '首页搜索框'
when action='on_click_navbar_search' and page_name='welfare_home' then '美购首页搜索框'
when action='on_click_navbar_search' and page_name='category' then '品类聚合页搜索框'
when action='on_click_navbar_search' and page_name='welfare_list' and referrer_link ='["home","category"]' then '来自品类聚合的美购列表页搜索框'
when action='on_click_navbar_search' and page_name='welfare_list' and referrer_link ='["welfare_home"]' then '来自美购首页的美购列表页搜索框'
when action in ('do_search','on_click_navbar_search')
and page_name in ('diary_detail','topic_detail','post_detail','user_post_detail'
,'doctor_post_detail','question_detail','answer_detail','question_answer_detail') then '内容详情页搜索框'
when action ='详情页高亮词' then '详情页高亮词搜索'
when action='大家都在看' then '首页feed大家都在看'
when action='热搜词' then '美购首页热搜词' else null end as search_entrance
,count(cl_id) as search_pv
,count(distinct cl_id) as search_uv
FROM
(
SELECT partition_date,device_os_type
,case WHEN active_type = '4' THEN '老活跃设备'
WHEN active_type in ('1','2') then '新增设备' END as active_type
,device_id
FROM online.ml_device_day_active_status
where partition_date = regexp_replace(DATE_SUB(current_date,1) ,'-','')
AND active_type in ('1','2','4')
and first_channel_source_type not in ('yqxiu1','yqxiu2','yqxiu3','yqxiu4','yqxiu5','mxyc1','mxyc2','mxyc3'
,'wanpu','jinshan','jx','maimai','zhuoyi','huatian','suopingjingling','mocha','mizhe','meika','lamabang'
,'js-az1','js-az2','js-az3','js-az4','js-az5','jfq-az1','jfq-az2','jfq-az3','jfq-az4','jfq-az5','toufang1'
,'toufang2','toufang3','toufang4','toufang5','toufang6','TF-toufang1','TF-toufang2','TF-toufang3','TF-toufang4'
,'TF-toufang5','tf-toufang1','tf-toufang2','tf-toufang3','tf-toufang4','tf-toufang5','benzhan','promotion_aso100'
,'promotion_qianka','promotion_xiaoyu','promotion_dianru','promotion_malioaso','promotion_malioaso-shequ'
,'promotion_shike','promotion_julang_jl03','promotion_zuimei')
AND first_channel_source_type not like 'promotion\_jf\_%'
)t1
join
(
SELECT partition_date,cl_id,page_name,action,params['referrer_link'] as referrer_link
FROM online.bl_hdfs_maidian_updates
where partition_date = regexp_replace(DATE_SUB(current_date,1) ,'-','')
and action in ('do_search','on_click_navbar_search')
union all
SELECT partition_date,cl_id,null as page_name,'大家都���看' as action, null as referrer_link
FROM online.bl_hdfs_maidian_updates
where partition_date = regexp_replace(DATE_SUB(current_date,1) ,'-','')
AND action = 'on_click_card'
AND params['in_page_pos']='猜你喜欢'
AND params['tab_name']='精选'
AND params['card_type']='search_word'
--AND page_name='home' android的page_name为空
union all
SELECT partition_date,cl_id,page_name,'热搜词' as action, null as referrer_link
FROM online.bl_hdfs_maidian_updates
where partition_date = regexp_replace(DATE_SUB(current_date,1) ,'-','')
AND action = 'on_click_card'
AND page_name='welfare_home'
AND params['card_type'] ='search_word'
AND params['in_page_pos']='大家都在搜'
union all
select partition_date,cl_id,null as page_name,'详情页高亮词' as action,null as referrer_link
from online.bl_hdfs_maidian_updates
where partition_date = regexp_replace(DATE_SUB(current_date,1) ,'-','')
and action='on_click_card'
and params['card_type']='highlight_word'
)t2
on t1.partition_date=t2.partition_date and t1.device_id=t2.cl_id
group by t1.partition_date
,t1.device_os_type
,t1.active_type
,case when action='on_click_navbar_search' and page_name='home' then '首页搜索框'
when action='on_click_navbar_search' and page_name='welfare_home' then '美购首页搜索框'
when action='on_click_navbar_search' and page_name='category' then '品类聚合页搜索框'
when action='on_click_navbar_search' and page_name='welfare_list' and referrer_link ='["home","category"]' then '来自品类聚合的美购列表页搜索框'
when action='on_click_navbar_search' and page_name='welfare_list' and referrer_link ='["welfare_home"]' then '来自美购首页的美购列表页搜索框'
when action in ('do_search','on_click_navbar_search')
and page_name in ('diary_detail','topic_detail','post_detail','user_post_detail'
,'doctor_post_detail','question_detail','answer_detail','question_answer_detail') then '内容详情页搜索框'
when action ='详情页高亮词' then '详情页高亮词搜索'
when action='大家都在看' then '首页feed大家都在看'
when action='热搜词' then '美购首页热搜词' else null end
having search_entrance is not null
)t
)n
LATERAL VIEW explode(n.search_entrance) v AS search_entrance
group by day_id,device_os_type,active_type,v.search_entrance;
\ No newline at end of file
SELECT
day_id AS `日期`
,query AS `关键词`
,search_pv AS `搜索量`
,search_uv AS `搜索uv`
,NVL(case when NVL(t2.page_more_pv,0)>0 then concat(round(t2.more_click_pv*100/t2.page_more_pv,2) ,'%') else 0 end, 0) as `搜索综合结果页内容卡片点击PV/搜索综合结果页浏览pv`
,NVL(case when NVL(t2.page_more_pv,0)>0 then concat(round(t2.more_click_10_pv*100/t2.page_more_pv,2) ,'%') else 0 end,0) as `搜索综合结果页前10内容卡片点击PV/搜索综合结果页浏览pv`
,NVL(case when NVL(t2.page_more_pv,0)>0 then concat(round(t2.more_click_5_diary_pv*100/t2.page_more_pv,2),'%') else 0 end,0) as `搜索综合结果页前5日记卡片点击PV/搜索综合结果页浏览pv`
,NVL(case when NVL(t2.page_more_pv,0)>0 then concat(round(t2.more_click_5_answer_pv*100/t2.page_more_pv,2),'%') else 0 end,0) as `搜索综合结果页前5问答卡片点击PV/搜索综合结果页浏览pv`
,NVL(case when NVL(t2.page_more_pv,0)>0 then concat(round(t2.more_click_5_topic_pv*100/t2.page_more_pv,2),'%') else 0 end,0) as `搜索综合结果页前5帖子卡片点击PV/搜索综合结果页浏览pv`
,NVL(case when NVL(t2.page_wel_pv,0)>0 then concat(round(t2.wel_click_pv*100/t2.page_wel_pv,2),'%') else 0 end,0) as `搜索美购结果页卡片点击PV/搜索美购结果页pv`
,NVL(case when NVL(t2.page_wel_pv,0)>0 then concat(round(t2.wel_click_10_pv*100/t2.page_wel_pv,2),'%') else 0 end,0) as `搜索美购结果页前10卡片点击PV/搜索美购结果页pv`
,NVL(case when NVL(t2.page_wel_pv,0)>0 then concat(round(t2.wel_click_5_pv*100/t2.page_wel_pv,2),'%') else 0 end,0) as `搜索美购结果页前5卡片点击PV/搜索美购结果页pv`
,NVL(case when NVL(t2.page_diary_pv,0)>0 then concat(round(t2.diary_click_pv*100/t2.page_diary_pv,2),'%') else 0 end,0) as `搜索日记结果页卡片点击PV/搜索日记结果页pv`
,NVL(case when NVL(t2.page_diary_pv,0)>0 then concat(round(t2.diary_click_10_pv*100/t2.page_diary_pv,2),'%') else 0 end,0) as `搜索日记结果页前10卡片点击PV/搜索日记结果页pv`
,NVL(case when NVL(t2.page_diary_pv,0)>0 then concat(round(t2.diary_click_5_pv*100/t2.page_diary_pv,2),'%') else 0 end,0) as `搜索日记结果页前5卡片点击PV/搜索日记结果页pv`
,search_more_pv AS `综合tab下的搜索的点击pv`
,page_more_pv AS `搜索综合结果页浏览PV`
,more_click_pv AS `搜索综合结果页内容卡片点击PV`
,more_click_10_pv AS `搜索综合结果页前10内容卡片点击PV`
,more_click_5_diary_pv AS `搜索综合结果页前5日记卡片点击PV`
,more_click_5_answer_pv AS `搜索综合结果页前5问答卡片点击PV`
,more_click_5_topic_pv AS `搜索综合结果页前5帖子卡片点击PV`
,search_wel_pv AS `美购tab下的搜索的点击pv`
,page_wel_pv AS `搜索美购结果页浏览pv`
,wel_click_pv AS `搜索美购结果页卡片点击PV`
,wel_click_10_pv AS `搜索美购结果页前10卡片点击PV`
,wel_click_5_pv AS `搜索美购结果页前5卡片点击PV`
,search_diary_pv AS `日记tab下的搜索的点击pv`
,page_diary_pv AS `搜索日记结果页浏览pv`
,diary_click_pv AS `搜索日记结果页卡片点击PV`
,diary_click_10_pv AS `搜索日记结果页前10卡片点击PV`
,diary_click_5_pv AS `搜索日记结果页前5卡片点击PV`
FROM pm.tl_pm_search_result_click_rate_d
WHERE partition_day>='20200619' and partition_day<=regexp_replace(DATE_SUB(current_date,1) ,'-','')
order by `日期` desc,`搜索量` desc,`关键词`
INSERT OVERWRITE TABLE pm.tl_pm_search_click_path_d PARTITION (PARTITION_DAY = #partition_day)
SELECT day_id as day_id
,device_os_type as device_os_type
,active_type as active_type
,v.search_entrance as search_entrance
,sum(search_pv) as click_search_pv
,sum(search_uv) as click_search_uv
FROM
(
SELECT day_id,device_os_type,active_type,array(search_entrance,'合计') as search_entrance
,search_pv,search_uv
FROM
(
SELECT t1.partition_date as day_id
,t1.device_os_type
,t1.active_type
,case when action='on_click_navbar_search' and page_name='home' then '首页搜索框'
when action='on_click_navbar_search' and page_name='welfare_home' then '美购首页搜索框'
when action='on_click_navbar_search' and page_name='category' then '品类聚合页搜索框'
when action='on_click_navbar_search' and page_name='welfare_list' and referrer_link ='["home","category"]' then '来自品类聚合的美购列表页搜索框'
when action='on_click_navbar_search' and page_name='welfare_list' and referrer_link ='["welfare_home"]' then '来自美购首页的美购列表页搜索框'
when action in ('do_search','on_click_navbar_search')
and page_name in ('diary_detail','topic_detail','post_detail','user_post_detail'
,'doctor_post_detail','question_detail','answer_detail','question_answer_detail') then '内容详情页搜索框'
when action ='详情页高亮词' then '详情页高亮词搜索'
when action='大家都在看' then '首页feed大家都在看'
when action='热搜词' then '美购首页热搜词' else null end as search_entrance
,count(cl_id) as search_pv
,count(distinct cl_id) as search_uv
FROM
(
SELECT partition_date,device_os_type
,case WHEN active_type = '4' THEN '老活跃设备'
WHEN active_type in ('1','2') then '新增设备' END as active_type
,device_id
FROM online.ml_device_day_active_status
where partition_date = regexp_replace(DATE_SUB(current_date,1) ,'-','')
AND active_type in ('1','2','4')
and first_channel_source_type not in ('yqxiu1','yqxiu2','yqxiu3','yqxiu4','yqxiu5','mxyc1','mxyc2','mxyc3'
,'wanpu','jinshan','jx','maimai','zhuoyi','huatian','suopingjingling','mocha','mizhe','meika','lamabang'
,'js-az1','js-az2','js-az3','js-az4','js-az5','jfq-az1','jfq-az2','jfq-az3','jfq-az4','jfq-az5','toufang1'
,'toufang2','toufang3','toufang4','toufang5','toufang6','TF-toufang1','TF-toufang2','TF-toufang3','TF-toufang4'
,'TF-toufang5','tf-toufang1','tf-toufang2','tf-toufang3','tf-toufang4','tf-toufang5','benzhan','promotion_aso100'
,'promotion_qianka','promotion_xiaoyu','promotion_dianru','promotion_malioaso','promotion_malioaso-shequ'
,'promotion_shike','promotion_julang_jl03','promotion_zuimei')
AND first_channel_source_type not like 'promotion\_jf\_%'
)t1
join
(
SELECT partition_date,cl_id,page_name,action,params['referrer_link'] as referrer_link
FROM online.bl_hdfs_maidian_updates
where partition_date = regexp_replace(DATE_SUB(current_date,1) ,'-','')
and action in ('do_search','on_click_navbar_search')
union all
SELECT partition_date,cl_id,null as page_name,'大家都在看' as action, null as referrer_link
FROM online.bl_hdfs_maidian_updates
where partition_date = regexp_replace(DATE_SUB(current_date,1) ,'-','')
AND action = 'on_click_card'
AND params['in_page_pos']='猜你喜欢'
AND params['tab_name']='精选'
AND params['card_type']='search_word'
--AND page_name='home' android的page_name为空
union all
SELECT partition_date,cl_id,null as page_name,'热搜词' as action, null as referrer_link
FROM online.bl_hdfs_maidian_updates
where partition_date = regexp_replace(DATE_SUB(current_date,1) ,'-','')
AND action = 'on_click_card'
AND page_name='welfare_home'
AND params['card_type'] ='search_word'
AND params['in_page_pos']='大家都在搜'
union all
select partition_date,cl_id,null as page_name,'详情页高亮词' as action,null as referrer_link
from online.bl_hdfs_maidian_updates
where partition_date = regexp_replace(DATE_SUB(current_date,1) ,'-','')
and action='on_click_card'
and params['card_type']='highlight_word'
)t2
on t1.partition_date=t2.partition_date and t1.device_id=t2.cl_id
group by t1.partition_date
,t1.device_os_type
,t1.active_type
,case when action='on_click_navbar_search' and page_name='home' then '首页搜索框'
when action='on_click_navbar_search' and page_name='welfare_home' then '美购首页搜索框'
when action='on_click_navbar_search' and page_name='category' then '品类聚合页搜索框'
when action='on_click_navbar_search' and page_name='welfare_list' and referrer_link ='["home","category"]' then '来自品类聚合的美购列表页搜索框'
when action='on_click_navbar_search' and page_name='welfare_list' and referrer_link ='["welfare_home"]' then '来自美购首页的美购列表页搜索框'
when action in ('do_search','on_click_navbar_search')
and page_name in ('diary_detail','topic_detail','post_detail','user_post_detail'
,'doctor_post_detail','question_detail','answer_detail','question_answer_detail') then '内容详情页搜索框'
when action ='详情页高亮词' then '详情页高亮词搜索'
when action='大家都在看' then '首页feed大家都在看'
when action='热搜词' then '美购首页热搜词' else null end
having search_entrance is not null
)t
)n
LATERAL VIEW explode(n.search_entrance) v AS search_entrance
group by day_id,device_os_type,active_type,v.search_entrance
This diff is collapsed.
--***************************************************************
--*脚本名称: create_pm_c_op_co_content_dimen_d.sql
--*功能: 内容日报
--*业务名称: pm
--*输入数据:
--*作者: weiyimin@igengmei.com
--*更新时间: 2020-5-25 11:00
--***************************************************************
--设置全局变量&UDF
SET mapreduce.job.queuename=data;
--使用bl数据库
USE pm;
--创建BL层内部表
CREATE TABLE IF NOT EXISTS pm.tl_pm_recommend_strategy_d
(
day_id string comment '{"chs_name":"当天日期","description":"","etl":"","value":"","remark":""}',
device_os_type string comment '{"chs_name":"设备类型","description":"","etl":"","value":"","remark":""}',
active_type string comment '{"chs_name":"活跃类型","description":"","etl":"","value":"","remark":""}',
card_content_type string comment '{"chs_name":"卡片类型","description":"","etl":"","value":"","remark":""}',
recommend_type string comment '{"chs_name":"推荐类型","description":"","etl":"","value":"","remark":""}',
home_ctr string comment '{"chs_name":"首页卡片点击PV/首页卡片精准曝光PV","description":"","etl":"","value":"","remark":""}',
second_rate string comment '{"chs_name":"来自首页推荐内容卡片的的总商业二跳pv/首页卡片精准曝光PV","description":"","etl":"","value":"","remark":""}',
first_rate string comment '{"chs_name":"来自首页推荐内容卡片的的总商业二跳pv/首页卡片点击PV","description":"","etl":"","value":"","remark":""}',
card_click BIGINT comment '{"chs_name":"首页卡片点击PV","description":"","etl":"","value":"","remark":""}',
card_exposure BIGINT comment '{"chs_name":"首页卡片精准曝光PV","description":"","etl":"","value":"","remark":""}',
total_second_click BIGINT comment '{"chs_name":"来自首页卡片的总商业二跳pv(包含页面上搜索及卡片点击)","description":"","etl":"","value":"","remark":""}',
avg_page_stay double comment '{"chs_name":"来自首页卡片的单PV平均浏览时长","description":"","etl":"","value":"","remark":""}',
navbar_search BIGINT comment '{"chs_name":"来自首页卡片的搜索框+搜索按钮点击PV","description":"","etl":"","value":"","remark":""}',
highlight_word BIGINT comment '{"chs_name":"来自首页卡片的文内搜索点击PV","description":"","etl":"","value":"","remark":""}',
self_welfare_card BIGINT comment '{"chs_name":"来自首页卡片的商品卡片点击PV","description":"","etl":"","value":"","remark":""}',
recommend_welfare_card BIGINT comment '{"chs_name":"来自首页卡片的推荐商品+查看全部商品点击pv","description":"","etl":"","value":"","remark":""}',
recommend_content_card BIGINT comment '{"chs_name":"来自首页卡片的推荐内容点击pv","description":"","etl":"","value":"","remark":""}',
recommend_special_card BIGINT comment '{"chs_name":"来自首页卡片的推荐专题点击pv","description":"","etl":"","value":"","remark":""}',
transfer_card BIGINT comment '{"chs_name":"来自首页卡片的转诊点击pv","description":"","etl":"","value":"","remark":""}',
video_consultation BIGINT comment '{"chs_name":"来自首页卡片的视频面诊点击pv","description":"","etl":"","value":"","remark":""}'
)comment '首页推荐策略日报'
PARTITIONED BY (PARTITION_DAY STRING comment '分区日期')
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '\t'
COLLECTION ITEMS TERMINATED BY '\002'
MAP KEYS TERMINATED BY '\003'
LINES TERMINATED BY '\n'
STORED AS TEXTFILE;
\ 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