AND first_channel_source_type not LIKE 'promotion\_jf\_%'
AND first_channel_source_type not LIKE 'promotion\_jf\_%'
)t1
)t1 JOIN
JOIN
(--精准曝光,卡片id和session_id去重
(--卡片,卡片id和session_id去重
SELECT partition_date,
card_content_type,
SELECT partition_date,
cl_id,
cl_id
v.recommend_type,
from
card_id,
( SELECT partition_date,
count(distinct app_session_id) as session_pv
cl_id,
FROM
count(distinct app_session_id) as session_pv0
(
FROM
SELECT partition_date,
(
cl_id,
SELECT partition_date,
case when card_content_type in ('qa','answer') then 'qa'
cl_id,
when card_content_type in ('special_pool') then 'special' else card_content_type end as card_content_type,
case when params['card_content_type'] in ('qa','answer') then 'qa'
CASE when transaction_type in ('fmctr','samecity_fmctr') then array('fmctr','合计')
when params['card_content_type'] in ('special_pool') then 'special' else params['card_content_type'] end as card_content_type,
when transaction_type in ('high_quality_fmctr') then array('high_quality_fmctr','合计')
CASE when params['transaction_type'] in ('fmctr','samecity_fmctr') then array('fmctr','合计')
WHEN (transaction_type like '%ctr' and transaction_type not in ('high_quality_ctr','high_quality_fmctr','fmctr','samecity_fmctr') ) THEN array('ctr预估','合计')
when params['transaction_type'] in ('high_quality_fmctr') then array('high_quality_fmctr','合计')
when transaction_type in ('high_quality_ctr') then array('high_quality_ctr','合计')
WHEN (params['transaction_type'] like '%ctr' and params['transaction_type'] not in ('high_quality_ctr','high_quality_fmctr','fmctr','samecity_fmctr')) THEN array('ctr预估','合计')
WHEN transaction_type like '%cvr' THEN array('cvr预估','合计')
when params['transaction_type'] in ('high_quality_ctr') then array('high_quality_ctr','合计')
WHEN transaction_type in ('-1','smr') THEN array('smr','合计')
WHEN params['transaction_type'] like '%cvr' THEN array('cvr预估','合计')
when transaction_type in ('pgc','hotspot') then array('热点卡片')
WHEN params['transaction_type'] in ('-1','smr') THEN array('smr','合计')
when transaction_type in ('newdata') then array('保量卡片')
when params['transaction_type'] in ('pgc','hotspot') then array('热点卡片')
when transaction_type in ('hotspot_feed') then array('hotspot_feed','合计')
when params['transaction_type'] in ('newdata') then array('保量卡片')
when transaction_type in ('aistragegy') then array('新用户AI帖优先','合计')
when params['transaction_type'] in ('hotspot_feed') then array('hotspot_feed','合计')
when transaction_type in ('excestragegy') then array('新用户精华帖优先','合计')
when params['transaction_type'] in ('aistragegy') then array('新用户AI帖优先','合计')
when transaction_type in ('FIXEDSTRATEGY') then array('新氧新用户策略一','合计')
when params['transaction_type'] in ('excestragegy') then array('新用户精华帖优先','合计')
when transaction_type in ('FIXEDSTRATEGY_VIDEO') then array('新氧新用户策略二','合计')
when params['transaction_type'] in ('FIXEDSTRATEGY') then array('新氧新用户策略一','合计')
when transaction_type like 'deeplink%' then array('deeplink策略','合计')
when params['transaction_type'] in ('FIXEDSTRATEGY_VIDEO') then array('新氧新用户策略二','合计')
end AS recommend_type,
when params['transaction_type'] like 'deeplink%' then array('deeplink策略','合计')
card_id,
end AS recommend_type,
app_session_id
params['card_id'] as card_id,
from online.ml_community_precise_exposure_detail
app_session_id
WHERE partition_date='{partition_day}'
from online.bl_hdfs_maidian_updates
AND action in ('page_precise_exposure','home_choiceness_card_exposure') --7745版本action改为page_precise_exposure
WHERE partition_date={partition_day}
AND is_exposure = '1' ----精准曝光
AND action='on_click_card'
AND page_name ='home'
AND params['page_name'] ='home'
AND tab_name = '精选'
AND params['tab_name'] = '精选'
AND (transaction_type in ('-1','smr','hotspot','pgc','newdata','hotspot_feed','aistragegy','excestragegy','FIXEDSTRATEGY','FIXEDSTRATEGY_VIDEO')
AND (params['transaction_type'] in ('-1','smr','hotspot','pgc','newdata','hotspot_feed','aistragegy','excestragegy','FIXEDSTRATEGY','FIXEDSTRATEGY_VIDEO')
or transaction_type like '%ctr' or transaction_type like '%cvr' or transaction_type like 'deeplink%')
or params['transaction_type'] like '%ctr' or params['transaction_type'] like '%cvr' or params['transaction_type'] like 'deeplink%')
AND card_content_type in ('qa','diary','user_post','answer','special_pool')
AND params['card_content_type'] in ('qa','diary','user_post','answer','special_pool')
group by partition_date,
GROUP BY partition_date,
case when card_content_type in ('qa','answer') then 'qa'
cl_id,
when card_content_type in ('special_pool') then 'special' else card_content_type end,
case when params['card_content_type'] in ('qa','answer') then 'qa'
cl_id,
when params['card_content_type'] in ('special_pool') then 'special' else params['card_content_type'] end,
CASE when transaction_type in ('fmctr','samecity_fmctr') then array('fmctr','合计')
CASE when params['transaction_type'] in ('fmctr','samecity_fmctr') then array('fmctr','合计')
when transaction_type in ('high_quality_fmctr') then array('high_quality_fmctr','合计')
when params['transaction_type'] in ('high_quality_fmctr') then array('high_quality_fmctr','合计')
WHEN (transaction_type like '%ctr' and transaction_type not in ('high_quality_ctr','high_quality_fmctr','fmctr','samecity_fmctr')) THEN array('ctr预估','合计')
WHEN (params['transaction_type'] like '%ctr' and params['transaction_type'] not in ('high_quality_ctr','high_quality_fmctr','fmctr','samecity_fmctr')) THEN array('ctr预估','合计')
when transaction_type in ('high_quality_ctr') then array('high_quality_ctr','合计')
when params['transaction_type'] in ('high_quality_ctr') then array('high_quality_ctr','合计')
WHEN transaction_type like '%cvr' THEN array('cvr预估','合计')
WHEN params['transaction_type'] like '%cvr' THEN array('cvr预估','合计')
WHEN transaction_type in ('-1','smr') THEN array('smr','合计')
WHEN params['transaction_type'] in ('-1','smr') THEN array('smr','合计')
when transaction_type in ('pgc','hotspot') then array('热点卡片')
when params['transaction_type'] in ('pgc','hotspot') then array('热点卡片')
when transaction_type in ('newdata') then array('保量卡片')
when params['transaction_type'] in ('newdata') then array('保量卡片')
when transaction_type in ('hotspot_feed') then array('hotspot_feed','合计')
when params['transaction_type'] in ('hotspot_feed') then array('hotspot_feed','合计')
when transaction_type in ('aistragegy') then array('新用户AI帖优先','合计')
when params['transaction_type'] in ('aistragegy') then array('新用户AI帖优先','合计')
when transaction_type in ('excestragegy') then array('新用户精华帖优先','合计')
when params['transaction_type'] in ('excestragegy') then array('新用户精华帖优先','合计')
when transaction_type in ('FIXEDSTRATEGY') then array('新氧新用户策略一','合计')
when params['transaction_type'] in ('FIXEDSTRATEGY') then array('新氧新用户策略一','合计')
when transaction_type in ('FIXEDSTRATEGY_VIDEO') then array('新氧新用户策略二','合计')
when params['transaction_type'] in ('FIXEDSTRATEGY_VIDEO') then array('新氧新用户策略二','合计')
when transaction_type like 'deeplink%' then array('deeplink策略','合计') end,
when params['transaction_type'] like 'deeplink%' then array('deeplink策略','合计') end,
card_id,
params['card_id'],
app_session_id
app_session_id
)a
)a
LATERAL VIEW explode (a.recommend_type) v as recommend_type
LATERAL VIEW explode (a.recommend_type) v as recommend_type
group by partition_date,card_content_type,cl_id,v.recommend_type,card_id
group by partition_date,card_content_type,cl_id,v.recommend_type,card_id having session_pv0 >0
)t2
on t1.device_id=t2.cl_id and t1.partition_date=t2.partition_date
UNION
LEFT JOIN
SELECT partition_date,
(--卡片,卡片id和session_id去重
cl_id,
SELECT partition_date,
count(distinct card_id) as session_pv0
card_content_type,
FROM
cl_id,
(SELECT partition_date,
v.recommend_type,
cl_id,
card_id,
case when card_content_type in ('qa','answer') then 'qa'
count(distinct app_session_id) as session_pv
when card_content_type in ('special_pool') then 'special' else card_content_type end as card_content_type,
FROM
CASE when transaction_type in ('fmctr','samecity_fmctr') then array('fmctr','合计')
(
when transaction_type in ('high_quality_fmctr') then array('high_quality_fmctr','合计')
SELECT partition_date,
WHEN (transaction_type like '%ctr' and transaction_type not in ('high_quality_ctr','high_quality_fmctr','fmctr','samecity_fmctr') ) THEN array('ctr预估','合计')
cl_id,
when transaction_type in ('high_quality_ctr') then array('high_quality_ctr','合计')
case when params['card_content_type'] in ('qa','answer') then 'qa'
WHEN transaction_type like '%cvr' THEN array('cvr预估','合计')
when params['card_content_type'] in ('special_pool') then 'special' else params['card_content_type'] end as card_content_type,
WHEN transaction_type in ('-1','smr') THEN array('smr','合计')
CASE when params['transaction_type'] in ('fmctr','samecity_fmctr') then array('fmctr','合计')
when transaction_type in ('pgc','hotspot') then array('热点卡片')
when params['transaction_type'] in ('high_quality_fmctr') then array('high_quality_fmctr','合计')
when transaction_type in ('newdata') then array('保量卡片')
WHEN (params['transaction_type'] like '%ctr' and params['transaction_type'] not in ('high_quality_ctr','high_quality_fmctr','fmctr','samecity_fmctr')) THEN array('ctr预估','合计')
when transaction_type in ('hotspot_feed') then array('hotspot_feed','合计')
when params['transaction_type'] in ('high_quality_ctr') then array('high_quality_ctr','合计')
when transaction_type in ('aistragegy') then array('新用户AI帖优先','合计')
WHEN params['transaction_type'] like '%cvr' THEN array('cvr预估','合计')
when transaction_type in ('excestragegy') then array('新用户精华帖优先','合计')
WHEN params['transaction_type'] in ('-1','smr') THEN array('smr','合计')
when transaction_type in ('FIXEDSTRATEGY') then array('新氧新用户策略一','合计')
when params['transaction_type'] in ('pgc','hotspot') then array('热点卡片')
when transaction_type in ('FIXEDSTRATEGY_VIDEO') then array('新氧新用户策略二','合计')
when params['transaction_type'] in ('newdata') then array('保量卡片')
when transaction_type like 'deeplink%' then array('deeplink策略','合计')
when params['transaction_type'] in ('hotspot_feed') then array('hotspot_feed','合计')
end AS recommend_type,
when params['transaction_type'] in ('aistragegy') then array('新用户AI帖优先','合计')
card_id,
when params['transaction_type'] in ('excestragegy') then array('新用户精华帖优先','合计')
app_session_id
when params['transaction_type'] in ('FIXEDSTRATEGY') then array('新氧新用户策略一','合计')
from online.ml_community_precise_exposure_detail
when params['transaction_type'] in ('FIXEDSTRATEGY_VIDEO') then array('新氧新用户策略二','合计')
WHERE partition_date={partition_day}
when params['transaction_type'] like 'deeplink%' then array('deeplink策略','合计')
AND action in ('page_precise_exposure','home_choiceness_card_exposure') --7745版本action改为page_precise_exposure
end AS recommend_type,
AND is_exposure = '1' ----精准曝光
params['card_id'] as card_id,
AND page_name ='home'
app_session_id
AND tab_name = '精选'
from online.bl_hdfs_maidian_updates
AND (transaction_type in ('-1','smr','hotspot','pgc','newdata','hotspot_feed','aistragegy','excestragegy','FIXEDSTRATEGY','FIXEDSTRATEGY_VIDEO')
WHERE partition_date='{partition_day}'
or transaction_type like '%ctr' or transaction_type like '%cvr' or transaction_type like 'deeplink%')
AND action='on_click_card'
AND card_content_type in ('qa','diary','user_post','answer','special_pool')
AND params['page_name'] ='home'
group by partition_date,
AND params['tab_name'] = '精选'
case when card_content_type in ('qa','answer') then 'qa'
AND (params['transaction_type'] in ('-1','smr','hotspot','pgc','newdata','hotspot_feed','aistragegy','excestragegy','FIXEDSTRATEGY','FIXEDSTRATEGY_VIDEO')
when card_content_type in ('special_pool') then 'special' else card_content_type end,
or params['transaction_type'] like '%ctr' or params['transaction_type'] like '%cvr' or params['transaction_type'] like 'deeplink%')
cl_id,
AND params['card_content_type'] in ('qa','diary','user_post','answer','special_pool')
CASE when transaction_type in ('fmctr','samecity_fmctr') then array('fmctr','合计')
GROUP BY partition_date,
when transaction_type in ('high_quality_fmctr') then array('high_quality_fmctr','合计')
cl_id,
WHEN (transaction_type like '%ctr' and transaction_type not in ('high_quality_ctr','high_quality_fmctr','fmctr','samecity_fmctr')) THEN array('ctr预估','合计')
case when params['card_content_type'] in ('qa','answer') then 'qa'
when transaction_type in ('high_quality_ctr') then array('high_quality_ctr','合计')
when params['card_content_type'] in ('special_pool') then 'special' else params['card_content_type'] end,
WHEN transaction_type like '%cvr' THEN array('cvr预估','合计')
CASE when params['transaction_type'] in ('fmctr','samecity_fmctr') then array('fmctr','合计')
WHEN transaction_type in ('-1','smr') THEN array('smr','合计')
when params['transaction_type'] in ('high_quality_fmctr') then array('high_quality_fmctr','合计')
when transaction_type in ('pgc','hotspot') then array('热点卡片')
WHEN (params['transaction_type'] like '%ctr' and params['transaction_type'] not in ('high_quality_ctr','high_quality_fmctr','fmctr','samecity_fmctr')) THEN array('ctr预估','合计')
when transaction_type in ('newdata') then array('保量卡片')
when params['transaction_type'] in ('high_quality_ctr') then array('high_quality_ctr','合计')
when transaction_type in ('hotspot_feed') then array('hotspot_feed','合计')
WHEN params['transaction_type'] like '%cvr' THEN array('cvr预估','合计')
when transaction_type in ('aistragegy') then array('新用户AI帖优先','合计')
WHEN params['transaction_type'] in ('-1','smr') THEN array('smr','合计')
when transaction_type in ('excestragegy') then array('新用户精华帖优先','合计')
when params['transaction_type'] in ('pgc','hotspot') then array('热点卡片')
when transaction_type in ('FIXEDSTRATEGY') then array('新氧新用户策略一','合计')
when params['transaction_type'] in ('newdata') then array('保量卡片')
when transaction_type in ('FIXEDSTRATEGY_VIDEO') then array('新氧新用户策略二','合计')
when params['transaction_type'] in ('hotspot_feed') then array('hotspot_feed','合计')
when transaction_type like 'deeplink%' then array('deeplink策略','合计') end,
when params['transaction_type'] in ('aistragegy') then array('新用户AI帖优先','合计')
card_id,
when params['transaction_type'] in ('excestragegy') then array('新用户精华帖优先','合计')
app_session_id
when params['transaction_type'] in ('FIXEDSTRATEGY') then array('新氧新用户策略一','合计')
)a
when params['transaction_type'] in ('FIXEDSTRATEGY_VIDEO') then array('新氧新用户策略二','合计')
LATERAL VIEW explode (a.recommend_type) v as recommend_type
when params['transaction_type'] like 'deeplink%' then array('deeplink策略','合计') end,
group by partition_date,cl_id having session_pv0 >= 4) group by partition_date,cl_id
params['card_id'],
) t0 on t1.device_id = t0.cl_id
app_session_id
LEFT JOIN
)a
(--精准曝光,卡片id和session_id去重
LATERAL VIEW explode (a.recommend_type) v as recommend_type
SELECT partition_date,
group by partition_date,card_content_type,cl_id,v.recommend_type,card_id
card_content_type,
)t3
cl_id,
on t2.partition_date=t3.partition_date
v.recommend_type,
and t2.cl_id=t3.cl_id
card_id,
and t2.card_id=t3.card_id
count(distinct app_session_id) as session_pv
and t2.card_content_type=t3.card_content_type
FROM
and t2.recommend_type=t3.recommend_type
(
LEFT JOIN
SELECT partition_date,
(--页面浏览时长
cl_id,
select partition_date,cl_id,coalesce(b.id,a.business_id) as business_id,a.page_name
case when card_content_type in ('qa','answer') then 'qa'
,sum(page_stay) as page_stay
when card_content_type in ('special_pool') then 'special' else card_content_type end as card_content_type,
from
CASE when transaction_type in ('fmctr','samecity_fmctr') then array('fmctr','合计')
(
when transaction_type in ('high_quality_fmctr') then array('high_quality_fmctr','合计')
SELECT partition_date,cl_id,business_id,
WHEN (transaction_type like '%ctr' and transaction_type not in ('high_quality_ctr','high_quality_fmctr','fmctr','samecity_fmctr') ) THEN array('ctr预估','合计')
case when page_name in ('diary_detail','topic_detail') then 'diary'
when transaction_type in ('high_quality_ctr') then array('high_quality_ctr','合计')
when page_name in ('post_detail','user_post_detail','doctor_post_detail') then 'user_post'
WHEN transaction_type like '%cvr' THEN array('cvr预估','合计')
when page_name in ('question_detail','answer_detail','question_answer_detail') then 'qa'
WHEN transaction_type in ('-1','smr') THEN array('smr','合计')
when page_name in ('custom_special') then 'special' else null end as page_name,
when transaction_type in ('pgc','hotspot') then array('热点卡片')
page_stay,time_str
when transaction_type in ('newdata') then array('保量卡片')
FROM online.bl_hdfs_maidian_updates
when transaction_type in ('hotspot_feed') then array('hotspot_feed','合计')
WHERE partition_date='{partition_day}'
when transaction_type in ('aistragegy') then array('新用户AI帖优先','合计')
AND action='page_view'
when transaction_type in ('excestragegy') then array('新用户精华帖优先','合计')
AND page_name IN ('diary_detail','topic_detail','post_detail','user_post_detail','doctor_post_detail','question_detail','answer_detail','question_answer_detail','custom_special')
when transaction_type in ('FIXEDSTRATEGY') then array('新氧新用户策略一','合计')
AND referrer='home'
when transaction_type in ('FIXEDSTRATEGY_VIDEO') then array('新氧新用户策略二','合计')
AND page_stay>=0 AND page_stay<1000
when transaction_type like 'deeplink%' then array('deeplink策略','合计')
GROUP BY partition_date,cl_id,business_id,
end AS recommend_type,
case when page_name in ('diary_detail','topic_detail') then 'diary'
card_id,
when page_name in ('post_detail','user_post_detail','doctor_post_detail') then 'user_post'
app_session_id
when page_name in ('question_detail','answer_detail','question_answer_detail') then 'qa'
from online.ml_community_precise_exposure_detail
when page_name in ('custom_special') then 'special' else null end,page_stay,time_str
WHERE partition_date={partition_day}
)a
AND action in ('page_precise_exposure','home_choiceness_card_exposure') --7745版本action改为page_precise_exposure
left join
AND is_exposure = '1' ----精准曝光
(
AND page_name ='home'
select id,visual_page_id,'special' as page_name
AND tab_name = '精选'
from tl.tl_zx_api_special_pool
AND (transaction_type in ('-1','smr','hotspot','pgc','newdata','hotspot_feed','aistragegy','excestragegy','FIXEDSTRATEGY','FIXEDSTRATEGY_VIDEO')
where partition_day ='{partition_day}'
or transaction_type like '%ctr' or transaction_type like '%cvr' or transaction_type like 'deeplink%')
group by id,visual_page_id
AND card_content_type in ('qa','diary','user_post','answer','special_pool')
)b
group by partition_date,
on a.business_id=b.visual_page_id and a.page_name=b.page_name
case when card_content_type in ('qa','answer') then 'qa'
group by partition_date,cl_id,coalesce(b.id,a.business_id),a.page_name
when card_content_type in ('special_pool') then 'special' else card_content_type end,
)t4
cl_id,
on t4.partition_date=t3.partition_date
CASE when transaction_type in ('fmctr','samecity_fmctr') then array('fmctr','合计')
and t4.cl_id=t3.cl_id
when transaction_type in ('high_quality_fmctr') then array('high_quality_fmctr','合计')
and t4.business_id=t3.card_id
WHEN (transaction_type like '%ctr' and transaction_type not in ('high_quality_ctr','high_quality_fmctr','fmctr','samecity_fmctr')) THEN array('ctr预估','合计')
and t4.page_name=t3.card_content_type
when transaction_type in ('high_quality_ctr') then array('high_quality_ctr','合计')
LEFT JOIN
WHEN transaction_type like '%cvr' THEN array('cvr预估','合计')
(--页面浏览时长
WHEN transaction_type in ('-1','smr') THEN array('smr','合计')
select partition_date,cl_id,coalesce(b.id,a.business_id) as business_id,a.page_name
when transaction_type in ('pgc','hotspot') then array('热点卡片')
,count(1) as pv
when transaction_type in ('newdata') then array('保量卡片')
,count(case when page_stay>=20 then 1 end) as pv_20
when transaction_type in ('hotspot_feed') then array('hotspot_feed','合计')
from
when transaction_type in ('aistragegy') then array('新用户AI帖优先','合计')
(
when transaction_type in ('excestragegy') then array('新用户精华帖优先','合计')
SELECT partition_date,cl_id,business_id,
when transaction_type in ('FIXEDSTRATEGY') then array('新氧新用户策略一','合计')
case when page_name in ('diary_detail','topic_detail') then 'diary'
when transaction_type in ('FIXEDSTRATEGY_VIDEO') then array('新氧新用户策略二','合计')
when page_name in ('post_detail','user_post_detail','doctor_post_detail') then 'user_post'
when transaction_type like 'deeplink%' then array('deeplink策略','合计') end,
when page_name in ('question_detail','answer_detail','question_answer_detail') then 'qa'
card_id,
when page_name in ('custom_special') then 'special' else null end as page_name,time_str,page_stay
app_session_id
FROM online.bl_hdfs_maidian_updates
)a
WHERE partition_date='{partition_day}'
LATERAL VIEW explode (a.recommend_type) v as recommend_type
AND action='page_view'
group by partition_date,card_content_type,cl_id,v.recommend_type,card_id
AND page_name IN ('diary_detail','topic_detail','post_detail','user_post_detail','doctor_post_detail','question_detail','answer_detail','question_answer_detail','custom_special')
)t2
AND referrer='home'
on t0.cl_id=t2.cl_id and t0.partition_date=t2.partition_date
GROUP BY partition_date,cl_id,business_id,
LEFT JOIN
case when page_name in ('diary_detail','topic_detail') then 'diary'
(--卡片,卡片id和session_id去重
when page_name in ('post_detail','user_post_detail','doctor_post_detail') then 'user_post'
SELECT partition_date,
when page_name in ('question_detail','answer_detail','question_answer_detail') then 'qa'
card_content_type,
when page_name in ('custom_special') then 'special' else null end,time_str,page_stay
cl_id,
)a
v.recommend_type,
left join
card_id,
(--在8月份新增了内容专题卡片,需要转换下id
count(distinct app_session_id) as session_pv
select id,visual_page_id,'special' as page_name
FROM
from tl.tl_zx_api_special_pool
(
where partition_day ='{partition_day}'
SELECT partition_date,
group by id,visual_page_id
cl_id,
)b
case when params['card_content_type'] in ('qa','answer') then 'qa'
on a.business_id=b.visual_page_id and a.page_name=b.page_name
when params['card_content_type'] in ('special_pool') then 'special' else params['card_content_type'] end as card_content_type,
group by partition_date,cl_id,coalesce(b.id,a.business_id),a.page_name
CASE when params['transaction_type'] in ('fmctr','samecity_fmctr') then array('fmctr','合计')
)t4_pv
when params['transaction_type'] in ('high_quality_fmctr') then array('high_quality_fmctr','合计')
on t4_pv.partition_date=t3.partition_date
WHEN (params['transaction_type'] like '%ctr' and params['transaction_type'] not in ('high_quality_ctr','high_quality_fmctr','fmctr','samecity_fmctr')) THEN array('ctr预估','合计')
and t4_pv.cl_id=t3.cl_id
when params['transaction_type'] in ('high_quality_ctr') then array('high_quality_ctr','合计')
and t4_pv.business_id=t3.card_id
WHEN params['transaction_type'] like '%cvr' THEN array('cvr预估','合计')
and t4_pv.page_name=t3.card_content_type
WHEN params['transaction_type'] in ('-1','smr') THEN array('smr','合计')
LEFT JOIN
when params['transaction_type'] in ('pgc','hotspot') then array('热点卡片')
(--搜索框和点击行为
when params['transaction_type'] in ('newdata') then array('保量卡片')
select partition_date,cl_id,coalesce(b.id,a.business_id) as business_id,a.page_name,navbar_pv
when params['transaction_type'] in ('hotspot_feed') then array('hotspot_feed','合计')
from
when params['transaction_type'] in ('aistragegy') then array('新用户AI帖优先','合计')
(
when params['transaction_type'] in ('excestragegy') then array('新用户精华帖优先','合计')
SELECT partition_date,cl_id,business_id,
when params['transaction_type'] in ('FIXEDSTRATEGY') then array('新氧新用户策略一','合计')
case when page_name in ('diary_detail','topic_detail') then 'diary'
when params['transaction_type'] in ('FIXEDSTRATEGY_VIDEO') then array('新氧新用户策略二','合计')
when page_name in ('post_detail','user_post_detail','doctor_post_detail') then 'user_post'
when params['transaction_type'] like 'deeplink%' then array('deeplink策略','合计')
when page_name in ('question_detail','answer_detail','question_answer_detail') then 'qa'
end AS recommend_type,
when page_name in ('custom_special') then 'special' else null end as page_name,
params['card_id'] as card_id,
count(1) as navbar_pv
app_session_id
FROM online.bl_hdfs_maidian_updates
from online.bl_hdfs_maidian_updates
WHERE partition_date='{partition_day}'
WHERE partition_date={partition_day}
AND action in ('on_click_navbar_search','do_search')
AND action='on_click_card'
AND page_name IN ('diary_detail','topic_detail','post_detail','user_post_detail','doctor_post_detail','question_detail','answer_detail','question_answer_detail','custom_special')
AND params['page_name'] ='home'
AND (referrer='home' or
AND params['tab_name'] = '精选'
(params['referrer_link'] like '%[%' and
AND (params['transaction_type'] in ('-1','smr','hotspot','pgc','newdata','hotspot_feed','aistragegy','excestragegy','FIXEDSTRATEGY','FIXEDSTRATEGY_VIDEO')
or params['transaction_type'] like '%ctr' or params['transaction_type'] like '%cvr' or params['transaction_type'] like 'deeplink%')
group by partition_date,cl_id,business_id,
AND params['card_content_type'] in ('qa','diary','user_post','answer','special_pool')
case when page_name in ('diary_detail','topic_detail') then 'diary'
GROUP BY partition_date,
when page_name in ('post_detail','user_post_detail','doctor_post_detail') then 'user_post'
cl_id,
when page_name in ('question_detail','answer_detail','question_answer_detail') then 'qa'
case when params['card_content_type'] in ('qa','answer') then 'qa'
when page_name in ('custom_special') then 'special' else null end
when params['card_content_type'] in ('special_pool') then 'special' else params['card_content_type'] end,
)a
CASE when params['transaction_type'] in ('fmctr','samecity_fmctr') then array('fmctr','合计')
left join
when params['transaction_type'] in ('high_quality_fmctr') then array('high_quality_fmctr','合计')
(
WHEN (params['transaction_type'] like '%ctr' and params['transaction_type'] not in ('high_quality_ctr','high_quality_fmctr','fmctr','samecity_fmctr')) THEN array('ctr预估','合计')
select id,visual_page_id,'special' as page_name
when params['transaction_type'] in ('high_quality_ctr') then array('high_quality_ctr','合计')
from tl.tl_zx_api_special_pool
WHEN params['transaction_type'] like '%cvr' THEN array('cvr预估','合计')
where partition_day ='{partition_day}'
WHEN params['transaction_type'] in ('-1','smr') THEN array('smr','合计')
group by id,visual_page_id
when params['transaction_type'] in ('pgc','hotspot') then array('热点卡片')
)b
when params['transaction_type'] in ('newdata') then array('保量卡片')
on a.business_id=b.visual_page_id and a.page_name=b.page_name
when params['transaction_type'] in ('hotspot_feed') then array('hotspot_feed','合计')
)t5
when params['transaction_type'] in ('aistragegy') then array('新用户AI帖优先','合计')
on t5.partition_date=t3.partition_date
when params['transaction_type'] in ('excestragegy') then array('新用户精华帖优先','合计')
and t5.cl_id=t3.cl_id
when params['transaction_type'] in ('FIXEDSTRATEGY') then array('新氧新用户策略一','合计')
and t5.business_id=t3.card_id
when params['transaction_type'] in ('FIXEDSTRATEGY_VIDEO') then array('新氧新用户策略二','合计')
and t5.page_name=t3.card_content_type
when params['transaction_type'] like 'deeplink%' then array('deeplink策略','合计') end,
LEFT JOIN
params['card_id'],
(--点击高亮词
app_session_id
select partition_date,cl_id,coalesce(b.id,a.business_id) as business_id,a.page_name,highlight_pv
)a
from
LATERAL VIEW explode (a.recommend_type) v as recommend_type
(
group by partition_date,card_content_type,cl_id,v.recommend_type,card_id
SELECT partition_date,cl_id,business_id,
)t3
case when page_name in ('diary_detail','topic_detail') then 'diary'
on t2.partition_date=t3.partition_date
when page_name in ('post_detail','user_post_detail','doctor_post_detail') then 'user_post'
and t2.cl_id=t3.cl_id
when page_name in ('question_detail','answer_detail','question_answer_detail') then 'qa'
and t2.card_id=t3.card_id
when page_name in ('custom_special') then 'special' else null end as page_name,
and t2.card_content_type=t3.card_content_type
count(1) as highlight_pv
and t2.recommend_type=t3.recommend_type
FROM online.bl_hdfs_maidian_updates
LEFT JOIN
WHERE partition_date='{partition_day}'
(--页面浏览时长
AND action='on_click_card'
select partition_date,cl_id,coalesce(b.id,a.business_id) as business_id,a.page_name
and params['card_type']='highlight_word'
,sum(page_stay) as page_stay
AND page_name IN ('diary_detail','topic_detail','post_detail','user_post_detail','doctor_post_detail','question_detail','answer_detail','question_answer_detail','custom_special')
case when page_name in ('diary_detail','topic_detail') then 'diary'
group by partition_date,cl_id,business_id,
when page_name in ('post_detail','user_post_detail','doctor_post_detail') then 'user_post'
case when page_name in ('diary_detail','topic_detail') then 'diary'
when page_name in ('question_detail','answer_detail','question_answer_detail') then 'qa'
when page_name in ('post_detail','user_post_detail','doctor_post_detail') then 'user_post'
when page_name in ('custom_special') then 'special' else null end as page_name,
when page_name in ('question_detail','answer_detail','question_answer_detail') then 'qa'
page_stay,time_str
when page_name in ('custom_special') then 'special' else null end
FROM online.bl_hdfs_maidian_updates
)a
WHERE partition_date={partition_day}
left join
AND action='page_view'
(
AND page_name IN ('diary_detail','topic_detail','post_detail','user_post_detail','doctor_post_detail','question_detail','answer_detail','question_answer_detail','custom_special')
select id,visual_page_id,'special' as page_name
AND referrer='home'
from tl.tl_zx_api_special_pool
AND page_stay>=0 AND page_stay<1000
where partition_day ='{partition_day}'
GROUP BY partition_date,cl_id,business_id,
group by id,visual_page_id
case when page_name in ('diary_detail','topic_detail') then 'diary'
)b
when page_name in ('post_detail','user_post_detail','doctor_post_detail') then 'user_post'
on a.business_id=b.visual_page_id and a.page_name=b.page_name
when page_name in ('question_detail','answer_detail','question_answer_detail') then 'qa'
)t6
when page_name in ('custom_special') then 'special' else null end,page_stay,time_str
on t6.partition_date=t3.partition_date
)a
and t6.cl_id=t3.cl_id
left join
and t6.business_id=t3.card_id
(
and t6.page_name=t3.card_content_type
select id,visual_page_id,'special' as page_name
LEFT JOIN
from tl.tl_zx_api_special_pool
(--关联的美购卡片
where partition_day ={partition_day}
SELECT partition_date,cl_id,coalesce(b.id,a.business_id) as business_id,a.page_name,count(1) as self_wel_pv
group by id,visual_page_id
FROM
)b
(
on a.business_id=b.visual_page_id and a.page_name=b.page_name
SELECT partition_date,cl_id,business_id,app_session_id,params['card_id'] as card_id,
group by partition_date,cl_id,coalesce(b.id,a.business_id),a.page_name
case when page_name in ('diary_detail','topic_detail') then 'diary'
)t4
when page_name in ('post_detail','user_post_detail','doctor_post_detail') then 'user_post'
on t4.partition_date=t3.partition_date
when page_name in ('question_detail','answer_detail','question_answer_detail') then 'qa'
and t4.cl_id=t3.cl_id
when page_name in ('custom_special') then 'special' else null end as page_name,
and t4.business_id=t3.card_id
count(1) as pv
and t4.page_name=t3.card_content_type
FROM online.bl_hdfs_maidian_updates
LEFT JOIN
WHERE partition_date='{partition_day}'
(--页面浏览时长
AND (get_json_object(params['extra_param'], '$.type')='交互栏'
select partition_date,cl_id,coalesce(b.id,a.business_id) as business_id,a.page_name
or get_json_object(params['extra_param'], '$.jump_from')='msg_link'
,count(1) as pv
or params['in_page_pos']='top'
,count(case when page_stay>=20 then 1 end) as pv_20
or (params['in_page_pos']='bottom' and params['position'] is null and cl_type='android')
from
or (params['in_page_pos']='bottom' and params['card_but_pos'] is not null and cl_type='ios'))
(
AND action='on_click_card'
SELECT partition_date,cl_id,business_id,
and params['card_content_type']='service'
case when page_name in ('diary_detail','topic_detail') then 'diary'
AND page_name IN ('diary_detail','topic_detail')
when page_name in ('post_detail','user_post_detail','doctor_post_detail') then 'user_post'
AND (referrer='home' or
when page_name in ('question_detail','answer_detail','question_answer_detail') then 'qa'
(params['referrer_link'] like '%[%' and
when page_name in ('custom_special') then 'special' else null end as page_name,time_str,page_stay
group by partition_date,cl_id,business_id,app_session_id,params['card_id'],
WHERE partition_date={partition_day}
case when page_name in ('diary_detail','topic_detail') then 'diary'
AND action='page_view'
when page_name in ('post_detail','user_post_detail','doctor_post_detail') then 'user_post'
AND page_name IN ('diary_detail','topic_detail','post_detail','user_post_detail','doctor_post_detail','question_detail','answer_detail','question_answer_detail','custom_special')
when page_name in ('question_detail','answer_detail','question_answer_detail') then 'qa'
AND referrer='home'
when page_name in ('custom_special') then 'special' else null end
GROUP BY partition_date,cl_id,business_id,
)a
case when page_name in ('diary_detail','topic_detail') then 'diary'
left join
when page_name in ('post_detail','user_post_detail','doctor_post_detail') then 'user_post'
(
when page_name in ('question_detail','answer_detail','question_answer_detail') then 'qa'
select id,visual_page_id,'special' as page_name
when page_name in ('custom_special') then 'special' else null end,time_str,page_stay
from tl.tl_zx_api_special_pool
)a
where partition_day ='{partition_day}'
left join
group by id,visual_page_id
(--在8月份新增了内容专题卡片,需要转换下id
)b
select id,visual_page_id,'special' as page_name
on a.business_id=b.visual_page_id and a.page_name=b.page_name
from tl.tl_zx_api_special_pool
group by partition_date,cl_id,coalesce(b.id,a.business_id),a.page_name
where partition_day ={partition_day}
)t7
group by id,visual_page_id
on t7.partition_date=t3.partition_date
)b
and t7.cl_id=t3.cl_id
on a.business_id=b.visual_page_id and a.page_name=b.page_name
and t7.business_id=t3.card_id
group by partition_date,cl_id,coalesce(b.id,a.business_id),a.page_name
and t7.page_name=t3.card_content_type
)t4_pv
LEFT JOIN
on t4_pv.partition_date=t3.partition_date
(--推荐的美购卡片(需要排除作者消费的美购)
and t4_pv.cl_id=t3.cl_id
SELECT partition_date,cl_id,coalesce(b.id,a.business_id) as business_id,a.page_name,count(1) as recom_wel_pv
and t4_pv.business_id=t3.card_id
FROM
and t4_pv.page_name=t3.card_content_type
(
LEFT JOIN
SELECT partition_date,cl_id,business_id,app_session_id,params['card_id'] as card_id,
(--搜索框和点击行为
case when page_name in ('diary_detail','topic_detail') then 'diary'
select partition_date,cl_id,coalesce(b.id,a.business_id) as business_id,a.page_name,navbar_pv
when page_name in ('post_detail','user_post_detail','doctor_post_detail') then 'user_post'
from
when page_name in ('question_detail','answer_detail','question_answer_detail') then 'qa'
(
when page_name in ('custom_special') then 'special' else null end as page_name,
SELECT partition_date,cl_id,business_id,
count(1) as service_pv
case when page_name in ('diary_detail','topic_detail') then 'diary'
when page_name in ('post_detail','user_post_detail','doctor_post_detail') then 'user_post'
when page_name in ('question_detail','answer_detail','question_answer_detail') then 'qa'
when page_name in ('custom_special') then 'special' else null end as page_name,
count(1) as navbar_pv
FROM online.bl_hdfs_maidian_updates
WHERE partition_date={partition_day}
AND action in ('on_click_navbar_search','do_search')
AND page_name IN ('diary_detail','topic_detail','post_detail','user_post_detail','doctor_post_detail','question_detail','answer_detail','question_answer_detail','custom_special')
case when page_name in ('diary_detail','topic_detail') then 'diary'
when page_name in ('post_detail','user_post_detail','doctor_post_detail') then 'user_post'
when page_name in ('question_detail','answer_detail','question_answer_detail') then 'qa'
when page_name in ('custom_special') then 'special' else null end
)a
left join
(
select id,visual_page_id,'special' as page_name
from tl.tl_zx_api_special_pool
where partition_day ={partition_day}
group by id,visual_page_id
)b
on a.business_id=b.visual_page_id and a.page_name=b.page_name
)t5
on t5.partition_date=t3.partition_date
and t5.cl_id=t3.cl_id
and t5.business_id=t3.card_id
and t5.page_name=t3.card_content_type
LEFT JOIN
(--点击高亮词
select partition_date,cl_id,coalesce(b.id,a.business_id) as business_id,a.page_name,highlight_pv
from
(
SELECT partition_date,cl_id,business_id,
case when page_name in ('diary_detail','topic_detail') then 'diary'
when page_name in ('post_detail','user_post_detail','doctor_post_detail') then 'user_post'
when page_name in ('question_detail','answer_detail','question_answer_detail') then 'qa'
when page_name in ('custom_special') then 'special' else null end as page_name,
count(1) as highlight_pv
FROM online.bl_hdfs_maidian_updates
WHERE partition_date={partition_day}
AND action='on_click_card'
and params['card_type']='highlight_word'
AND page_name IN ('diary_detail','topic_detail','post_detail','user_post_detail','doctor_post_detail','question_detail','answer_detail','question_answer_detail','custom_special')
group by partition_date,cl_id,business_id,app_session_id,params['card_id'],
case when page_name in ('diary_detail','topic_detail') then 'diary'
when page_name in ('post_detail','user_post_detail','doctor_post_detail') then 'user_post'
when page_name in ('question_detail','answer_detail','question_answer_detail') then 'qa'
when page_name in ('custom_special') then 'special' else null end
)a
left join
(
select id,visual_page_id,'special' as page_name
from tl.tl_zx_api_special_pool
where partition_day ={partition_day}
group by id,visual_page_id
)b
on a.business_id=b.visual_page_id and a.page_name=b.page_name
group by partition_date,cl_id,coalesce(b.id,a.business_id),a.page_name
)t7
on t7.partition_date=t3.partition_date
and t7.cl_id=t3.cl_id
and t7.business_id=t3.card_id
and t7.page_name=t3.card_content_type
LEFT JOIN
(--推荐的美购卡片(需要排除作者消费的美购)
SELECT partition_date,cl_id,coalesce(b.id,a.business_id) as business_id,a.page_name,count(1) as recom_wel_pv
FROM
(
SELECT partition_date,cl_id,business_id,app_session_id,params['card_id'] as card_id,
case when page_name in ('diary_detail','topic_detail') then 'diary'
when page_name in ('post_detail','user_post_detail','doctor_post_detail') then 'user_post'
when page_name in ('question_detail','answer_detail','question_answer_detail') then 'qa'
when page_name in ('custom_special') then 'special' else null end as page_name,
count(1) as service_pv
FROM online.bl_hdfs_maidian_updates
WHERE partition_date={partition_day}
AND (action='on_click_card'and params['card_content_type']='service'
or action='on_click_button' and params['button_name']='unfold' and page_name in ('diary_detail','topic_detail','post_detail','user_post_detail','doctor_post_detail')
or action='on_click_button' and params['button_name'] = 'more_recommendations')
AND page_name IN ('diary_detail','topic_detail','post_detail','user_post_detail','doctor_post_detail','question_detail','answer_detail','question_answer_detail','custom_special')
group by partition_date,cl_id,business_id,app_session_id,params['card_id'],
case when page_name in ('diary_detail','topic_detail') then 'diary'
when page_name in ('post_detail','user_post_detail','doctor_post_detail') then 'user_post'
when page_name in ('question_detail','answer_detail','question_answer_detail') then 'qa'
when page_name in ('custom_special') then 'special' else null end
)a
left join
(
select id,visual_page_id,'special' as page_name
from tl.tl_zx_api_special_pool
where partition_day ={partition_day}
group by id,visual_page_id
)b
on a.business_id=b.visual_page_id and a.page_name=b.page_name
group by partition_date,cl_id,coalesce(b.id,a.business_id),a.page_name
)t8
on t8.partition_date=t3.partition_date
and t8.cl_id=t3.cl_id
and t8.business_id=t3.card_id
and t8.page_name=t3.card_content_type
LEFT JOIN
(--推荐的内容卡片
SELECT partition_date,cl_id,coalesce(b.id,a.business_id) as business_id,a.page_name,count(1) as recom_content_pv
FROM
(
SELECT partition_date,cl_id,business_id,app_session_id,params['card_id'] as card_id,
case when page_name in ('diary_detail','topic_detail') then 'diary'
when page_name in ('post_detail','user_post_detail','doctor_post_detail') then 'user_post'
when page_name in ('question_detail','answer_detail','question_answer_detail') then 'qa'
when page_name in ('custom_special') then 'special' else null end as page_name,
count(1) as service_pv
FROM online.bl_hdfs_maidian_updates
WHERE partition_date={partition_day}
AND action='on_click_card'
and params['card_content_type'] in ('qa','diary','user_post','answer')
AND page_name IN ('diary_detail','topic_detail','post_detail','user_post_detail','doctor_post_detail','question_detail','answer_detail','question_answer_detail','custom_special')
group by partition_date,cl_id,business_id,app_session_id,params['card_id'],
case when page_name in ('diary_detail','topic_detail') then 'diary'
when page_name in ('post_detail','user_post_detail','doctor_post_detail') then 'user_post'
when page_name in ('question_detail','answer_detail','question_answer_detail') then 'qa'
when page_name in ('custom_special') then 'special' else null end
)a
left join
(
select id,visual_page_id,'special' as page_name
from tl.tl_zx_api_special_pool
where partition_day ={partition_day}
group by id,visual_page_id
)b
on a.business_id=b.visual_page_id and a.page_name=b.page_name
group by partition_date,cl_id,coalesce(b.id,a.business_id),a.page_name
)t9
on t9.partition_date=t3.partition_date
and t9.cl_id=t3.cl_id
and t9.business_id=t3.card_id
and t9.page_name=t3.card_content_type
LEFT JOIN
(--视频面诊点击
select partition_date,cl_id,coalesce(b.id,a.business_id) as business_id,a.page_name,video_pv
from
(
SELECT partition_date,cl_id,business_id,
case when page_name in ('diary_detail','topic_detail') then 'diary'
when page_name in ('post_detail','user_post_detail','doctor_post_detail') then 'user_post'
when page_name in ('question_detail','answer_detail','question_answer_detail') then 'qa'
when page_name in ('custom_special') then 'special' else null end as page_name,
count(1) as video_pv
FROM online.bl_hdfs_maidian_updates
WHERE partition_date={partition_day}
AND action='on_click_button'
and params['button_name']='video_interview'
AND page_name IN ('diary_detail','topic_detail','post_detail','user_post_detail','doctor_post_detail','question_detail','answer_detail','question_answer_detail','custom_special')
case when page_name in ('diary_detail','topic_detail') then 'diary'
when page_name in ('post_detail','user_post_detail','doctor_post_detail') then 'user_post'
when page_name in ('question_detail','answer_detail','question_answer_detail') then 'qa'
when page_name in ('custom_special') then 'special' else null end
)a
left join
(
select id,visual_page_id,'special' as page_name
from tl.tl_zx_api_special_pool
where partition_day ={partition_day}
group by id,visual_page_id
)b
on a.business_id=b.visual_page_id and a.page_name=b.page_name
)t10
on t10.partition_date=t3.partition_date
and t10.cl_id=t3.cl_id
and t10.business_id=t3.card_id
and t10.page_name=t3.card_content_type
LEFT JOIN
(--转诊按钮点击
select partition_date,cl_id,coalesce(b.id,a.business_id) as business_id,a.page_name,referral_pv
from
(
SELECT partition_date,cl_id,business_id,
case when page_name in ('diary_detail','topic_detail') then 'diary'
when page_name in ('post_detail','user_post_detail','doctor_post_detail') then 'user_post'
when page_name in ('question_detail','answer_detail','question_answer_detail') then 'qa'
when page_name in ('custom_special') then 'special' else null end as page_name,
count(1) as referral_pv
FROM online.bl_hdfs_maidian_updates
WHERE partition_date={partition_day}
AND action='on_click_button'
and params['button_name']='referral'
AND page_name IN ('diary_detail','topic_detail','post_detail','user_post_detail','doctor_post_detail','question_detail','answer_detail','question_answer_detail','custom_special')
case when page_name in ('diary_detail','topic_detail') then 'diary'
when page_name in ('post_detail','user_post_detail','doctor_post_detail') then 'user_post'
when page_name in ('question_detail','answer_detail','question_answer_detail') then 'qa'
when page_name in ('custom_special') then 'special' else null end
)a
left join
(
select id,visual_page_id,'special' as page_name
from tl.tl_zx_api_special_pool
where partition_day ={partition_day}
group by id,visual_page_id
)b
on a.business_id=b.visual_page_id and a.page_name=b.page_name
)t11
on t11.partition_date=t3.partition_date
and t11.cl_id=t3.cl_id
and t11.business_id=t3.card_id
and t11.page_name=t3.card_content_type
LEFT JOIN
(--从帖子页到帖子页
SELECT partition_date,cl_id,params['referrer_id'] as business_id,
case when page_name in ('post_detail','user_post_detail','doctor_post_detail') then 'user_post'
else null end as page_name,
count(distinct params['business_id'],app_session_id) as post_pv
FROM online.bl_hdfs_maidian_updates
FROM online.bl_hdfs_maidian_updates
WHERE partition_date='{partition_day}'
WHERE partition_date={partition_day}
AND (action='on_click_card'and params['card_content_type']='service'
AND action='page_view'
or action='on_click_button' and params['button_name']='unfold' and page_name in ('diary_detail','topic_detail','post_detail','user_post_detail','doctor_post_detail')
AND page_name IN ('post_detail','user_post_detail','doctor_post_detail','custom_special')
or action='on_click_button' and params['button_name'] = 'more_recommendations')
AND (json_split(params['referrer_link'])[size(json_split(params['referrer_link']))-1]IN ('post_detail','user_post_detail','doctor_post_detail')
AND page_name IN ('diary_detail','topic_detail','post_detail','user_post_detail','doctor_post_detail','question_detail','answer_detail','question_answer_detail','custom_special')
and json_split(params['referrer_link'])[size(json_split(params['referrer_link']))-2]='home')
AND (referrer='home' or
group by partition_date,cl_id,params['referrer_id'],
(params['referrer_link'] like '%[%' and
case when page_name in ('post_detail','user_post_detail','doctor_post_detail') then 'user_post'
group by partition_date,cl_id,business_id,app_session_id,params['card_id'],
)t12
case when page_name in ('diary_detail','topic_detail') then 'diary'
on t12.partition_date=t3.partition_date
when page_name in ('post_detail','user_post_detail','doctor_post_detail') then 'user_post'
and t12.cl_id=t3.cl_id
when page_name in ('question_detail','answer_detail','question_answer_detail') then 'qa'
and t12.business_id=t3.card_id
when page_name in ('custom_special') then 'special' else null end
and t12.page_name=t3.card_content_type
)a
left join
left join
(
(--在帖子页点击帖子
select id,visual_page_id,'special' as page_name
SELECT partition_date,cl_id,params['business_id'] as business_id,
from tl.tl_zx_api_special_pool
case when page_name in ('post_detail','user_post_detail','doctor_post_detail') then 'user_post'
where partition_day ='{partition_day}'
else null end as page_name,
group by id,visual_page_id
count(distinct params['card_id'],app_session_id) as post_click_pv
)b
on a.business_id=b.visual_page_id and a.page_name=b.page_name
group by partition_date,cl_id,coalesce(b.id,a.business_id),a.page_name
)t8
on t8.partition_date=t3.partition_date
and t8.cl_id=t3.cl_id
and t8.business_id=t3.card_id
and t8.page_name=t3.card_content_type
LEFT JOIN
(--推荐的内容卡片
SELECT partition_date,cl_id,coalesce(b.id,a.business_id) as business_id,a.page_name,count(1) as recom_content_pv
FROM
(
SELECT partition_date,cl_id,business_id,app_session_id,params['card_id'] as card_id,
case when page_name in ('diary_detail','topic_detail') then 'diary'
when page_name in ('post_detail','user_post_detail','doctor_post_detail') then 'user_post'
when page_name in ('question_detail','answer_detail','question_answer_detail') then 'qa'
when page_name in ('custom_special') then 'special' else null end as page_name,
count(1) as service_pv
FROM online.bl_hdfs_maidian_updates
FROM online.bl_hdfs_maidian_updates
WHERE partition_date='{partition_day}'
WHERE partition_date={partition_day}
AND action='on_click_card'
AND action='on_click_card'
and params['card_content_type'] in ('qa','diary','user_post','answer')
and params['card_content_type'] in ('user_post')
AND page_name IN ('diary_detail','topic_detail','post_detail','user_post_detail','doctor_post_detail','question_detail','answer_detail','question_answer_detail','custom_special')
AND page_name IN ('post_detail','user_post_detail','doctor_post_detail')
group by partition_date,cl_id,business_id,app_session_id,params['card_id'],
group by partition_date,cl_id,params['business_id'],
case when page_name in ('diary_detail','topic_detail') then 'diary'
case when page_name in ('post_detail','user_post_detail','doctor_post_detail') then 'user_post'
when page_name in ('post_detail','user_post_detail','doctor_post_detail') then 'user_post'
else null end
when page_name in ('question_detail','answer_detail','question_answer_detail') then 'qa'
)t13
when page_name in ('custom_special') then 'special' else null end
on t13.partition_date=t3.partition_date
)a
and t13.cl_id=t3.cl_id
left join
and t13.business_id=t3.card_id
and t13.page_name=t3.card_content_type
LEFT JOIN
(
(
select id,visual_page_id,'special' as page_name
select distinct device_id
from tl.tl_zx_api_special_pool
from ML.ML_D_CT_DV_DEVICECLEAN_DIMEN_D
where partition_day ='{partition_day}'
where PARTITION_DAY = '{partition_day}'
group by id,visual_page_id
AND is_abnormal_device = 'true'
)b
)dev
on a.business_id=b.visual_page_id and a.page_name=b.page_name
on t2.cl_id=dev.device_id
group by partition_date,cl_id,coalesce(b.id,a.business_id),a.page_name
WHERE dev.device_id is null
)t9
GROUP BY t1.partition_date,t1.device_os_type,t1.active_type,t2.card_content_type,t2.recommend_type
on t9.partition_date=t3.partition_date
order by day_id,device_os_type,active_type,card_content_type,recommend_type
and t9.cl_id=t3.cl_id
and t9.business_id=t3.card_id
and t9.page_name=t3.card_content_type
LEFT JOIN
(--视频面诊点击
select partition_date,cl_id,coalesce(b.id,a.business_id) as business_id,a.page_name,video_pv
from
(
SELECT partition_date,cl_id,business_id,
case when page_name in ('diary_detail','topic_detail') then 'diary'
when page_name in ('post_detail','user_post_detail','doctor_post_detail') then 'user_post'
when page_name in ('question_detail','answer_detail','question_answer_detail') then 'qa'
when page_name in ('custom_special') then 'special' else null end as page_name,
count(1) as video_pv
FROM online.bl_hdfs_maidian_updates
WHERE partition_date='{partition_day}'
AND action='on_click_button'
and params['button_name']='video_interview'
AND page_name IN ('diary_detail','topic_detail','post_detail','user_post_detail','doctor_post_detail','question_detail','answer_detail','question_answer_detail','custom_special')
case when page_name in ('diary_detail','topic_detail') then 'diary'
when page_name in ('post_detail','user_post_detail','doctor_post_detail') then 'user_post'
when page_name in ('question_detail','answer_detail','question_answer_detail') then 'qa'
when page_name in ('custom_special') then 'special' else null end
)a
left join
(
select id,visual_page_id,'special' as page_name
from tl.tl_zx_api_special_pool
where partition_day ='{partition_day}'
group by id,visual_page_id
)b
on a.business_id=b.visual_page_id and a.page_name=b.page_name
)t10
on t10.partition_date=t3.partition_date
and t10.cl_id=t3.cl_id
and t10.business_id=t3.card_id
and t10.page_name=t3.card_content_type
LEFT JOIN
(--转诊按钮点击
select partition_date,cl_id,coalesce(b.id,a.business_id) as business_id,a.page_name,referral_pv
from
(
SELECT partition_date,cl_id,business_id,
case when page_name in ('diary_detail','topic_detail') then 'diary'
when page_name in ('post_detail','user_post_detail','doctor_post_detail') then 'user_post'
when page_name in ('question_detail','answer_detail','question_answer_detail') then 'qa'
when page_name in ('custom_special') then 'special' else null end as page_name,
count(1) as referral_pv
FROM online.bl_hdfs_maidian_updates
WHERE partition_date='{partition_day}'
AND action='on_click_button'
and params['button_name']='referral'
AND page_name IN ('diary_detail','topic_detail','post_detail','user_post_detail','doctor_post_detail','question_detail','answer_detail','question_answer_detail','custom_special')