select count(1),avg(session_pv) from (SELECT partition_date,
card_content_type,
cl_id,
v.recommend_type,
count(distinct app_session_id) as session_pv ,
count(app_session_id) as session_pv1
FROM
FROM
(
(
SELECT query
SELECT partition_date,
,count(t1.cl_id) as search_pv
cl_id,
,count(distinct t1.cl_id) as search_uv
case when card_content_type in ('qa','answer') then 'qa'
FROM
when card_content_type in ('special_pool') then 'special' else card_content_type end as card_content_type,
(
CASE when transaction_type in ('fmctr','samecity_fmctr') then array('fmctr','合计')
SELECT partition_date
when transaction_type in ('high_quality_fmctr') then array('high_quality_fmctr','合计')
,params['query'] as query
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','合计')
FROM online.bl_hdfs_maidian_updates
WHEN transaction_type like '%cvr' THEN array('cvr预估','合计')
WHERE partition_date >= {start_date}
WHEN transaction_type in ('-1','smr') THEN array('smr','合计')
AND partition_date < {end_date}
when transaction_type in ('pgc','hotspot') then array('热点卡片')
AND ((action = 'do_search' AND params['input_type']<>'everyone_watch') or action='search_result_click_search')
when transaction_type in ('newdata') then array('保量卡片')
when transaction_type in ('hotspot_feed') then array('hotspot_feed','合计')
UNION ALL
when transaction_type in ('aistragegy') then array('新用户AI帖优先','合计')
SELECT partition_date,params['query'] as query,cl_id
when transaction_type in ('excestragegy') then array('新用户精华帖优先','合计')
FROM online.bl_hdfs_maidian_updates
when transaction_type in ('FIXEDSTRATEGY') then array('新氧新用户策略一','合计')
WHERE partition_date >= {start_date}
when transaction_type in ('FIXEDSTRATEGY_VIDEO') then array('新氧新用户策略二','合计')
AND partition_date < {end_date}
when transaction_type like 'deeplink%' then array('deeplink策略','合计')
AND action = 'do_search'
end AS recommend_type,
and params['input_type']='everyone_watch'
card_id,
and params['tab']='精选'
app_session_id
and page_name='home'
from online.ml_community_precise_exposure_detail
AND params['query'] not in ('AI测颜值','AI测肤质') --这两个词不跳转搜索结果页
WHERE partition_date='20201105'
AND action in ('page_precise_exposure','home_choiceness_card_exposure') --7745版本action改为page_precise_exposure
UNION ALL
AND is_exposure = '1' ----精准曝光
SELECT partition_date,params['query'] as query,cl_id
AND page_name ='home'
FROM online.bl_hdfs_maidian_updates
AND tab_name = '精选'
WHERE partition_date >= {start_date}
AND (transaction_type in ('-1','smr','hotspot','pgc','newdata','hotspot_feed','aistragegy','excestragegy','FIXEDSTRATEGY','FIXEDSTRATEGY_VIDEO')
AND partition_date < {end_date}
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']='search_home'
group by partition_date,
case when card_content_type in ('qa','answer') then 'qa'
when card_content_type in ('special_pool') then 'special' else card_content_type end,
UNION ALL
cl_id,
SELECT partition_date
CASE when transaction_type in ('fmctr','samecity_fmctr') then array('fmctr','合计')
,params['card_name'] as query
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预估','合计')
FROM online.bl_hdfs_maidian_updates
when transaction_type in ('high_quality_ctr') then array('high_quality_ctr','合计')
WHERE partition_date >= {start_date}
WHEN transaction_type like '%cvr' THEN array('cvr预估','合计')
AND partition_date < {end_date}
WHEN transaction_type in ('-1','smr') THEN array('smr','合计')
AND action = 'on_click_card'
when transaction_type in ('pgc','hotspot') then array('热点卡片')
AND params['in_page_pos']='猜你喜欢'
when transaction_type in ('newdata') then array('保量卡片')
--AND params['tab_name']='精选'
when transaction_type in ('hotspot_feed') then array('hotspot_feed','合计')
AND params['card_type']='search_word'
when transaction_type in ('aistragegy') then array('新用户AI帖优先','合计')
AND params['card_name'] not in ('AI测颜值','AI测肤质') --这两个词不跳转搜索结果页
when transaction_type in ('excestragegy') then array('新用户精华帖优先','合计')
--AND page_name='home' android的page_name为空
when transaction_type in ('FIXEDSTRATEGY') then array('新氧新用户策略一','合计')
when transaction_type in ('FIXEDSTRATEGY_VIDEO') then array('新氧新用户策略二','合计')
UNION ALL
when transaction_type like 'deeplink%' then array('deeplink策略','合计') end,
SELECT partition_date
card_id,
,params['card_name'] as query
app_session_id
,cl_id
)a
FROM online.bl_hdfs_maidian_updates
LATERAL VIEW explode (a.recommend_type) v as recommend_type
WHERE partition_date >= {start_date}
group by partition_date,card_content_type,cl_id,v.recommend_type )