case when params['card_content_type'] in ('qa','answer') then 'qa'
when params['card_content_type'] in ('special_pool') then 'special' else params['card_content_type'] end as card_content_type,
CASE when params['transaction_type'] in ('fmctr','samecity_fmctr') then array('fmctr','合计')
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预估','合计')
when params['transaction_type'] in ('high_quality_ctr') then array('high_quality_ctr','合计')
WHEN params['transaction_type'] like '%cvr' THEN array('cvr预估','合计')
WHEN params['transaction_type'] in ('-1','smr') THEN array('smr','合计')
when params['transaction_type'] in ('pgc','hotspot') then array('热点卡片')
when params['transaction_type'] in ('newdata') then array('保量卡片')
when params['transaction_type'] in ('hotspot_feed') then array('hotspot_feed','合计')
when params['transaction_type'] in ('aistragegy') then array('新用户AI帖优先','合计')
when params['transaction_type'] in ('excestragegy') then array('新用户精华帖优先','合计')
when params['transaction_type'] in ('FIXEDSTRATEGY') then array('新氧新用户策略一','合计')
when params['transaction_type'] in ('FIXEDSTRATEGY_VIDEO') then array('新氧新用户策略二','合计')
when params['transaction_type'] like 'deeplink%' then array('deeplink策略','合计')
end AS recommend_type,
params['card_id'] as card_id,
app_session_id
from online.bl_hdfs_maidian_updates
WHERE partition_date={partition_day}
AND action='on_click_card'
AND params['page_name'] ='home'
AND params['tab_name'] = '精选'
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%')
AND params['card_content_type'] in ('qa','diary','user_post','answer','special_pool')
GROUP BY partition_date,
cl_id,
case when params['card_content_type'] in ('qa','answer') then 'qa'
when params['card_content_type'] in ('special_pool') then 'special' else params['card_content_type'] end,
CASE when params['transaction_type'] in ('fmctr','samecity_fmctr') then array('fmctr','合计')
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预估','合计')
when params['transaction_type'] in ('high_quality_ctr') then array('high_quality_ctr','合计')
WHEN params['transaction_type'] like '%cvr' THEN array('cvr预估','合计')
WHEN params['transaction_type'] in ('-1','smr') THEN array('smr','合计')
when params['transaction_type'] in ('pgc','hotspot') then array('热点卡片')
when params['transaction_type'] in ('newdata') then array('保量卡片')
when params['transaction_type'] in ('hotspot_feed') then array('hotspot_feed','合计')
when params['transaction_type'] in ('aistragegy') then array('新用户AI帖优先','合计')
when params['transaction_type'] in ('excestragegy') then array('新用户精华帖优先','合计')
when params['transaction_type'] in ('FIXEDSTRATEGY') then array('新氧新用户策略一','合计')
when params['transaction_type'] in ('FIXEDSTRATEGY_VIDEO') then array('新氧新用户策略二','合计')
when params['transaction_type'] like 'deeplink%' then array('deeplink策略','合计') end,
params['card_id'],
app_session_id
)a
LATERAL VIEW explode (a.recommend_type) v as recommend_type
group by partition_date,card_content_type,cl_id,v.recommend_type,card_id having session_pv0 >0
UNION
SELECT partition_date,
cl_id,
count(distinct card_id) as session_pv0
FROM
FROM
(SELECT partition_date,
(--找出user_id当天活跃的第一个设备id
cl_id,
SELECT user_id,partition_date,
case when card_content_type in ('qa','answer') then 'qa'
if(size(device_list) > 0, device_list [ 0 ], '') AS device_id
when card_content_type in ('special_pool') then 'special' else card_content_type end as card_content_type,
FROM online.ml_user_updates
CASE when transaction_type in ('fmctr','samecity_fmctr') then array('fmctr','合计')
WHERE partition_date='{today_str}'
when transaction_type in ('high_quality_fmctr') then array('high_quality_fmctr','合计')
)t1
WHEN (transaction_type like '%ctr' and transaction_type not in ('high_quality_ctr','high_quality_fmctr','fmctr','samecity_fmctr') ) THEN array('ctr预估','合计')
JOIN
when transaction_type in ('high_quality_ctr') then array('high_quality_ctr','合计')
( --医生账号
WHEN transaction_type like '%cvr' THEN array('cvr预估','合计')
SELECT distinct user_id
WHEN transaction_type in ('-1','smr') THEN array('smr','合计')
FROM online.tl_hdfs_doctor_view
when transaction_type in ('pgc','hotspot') then array('热点卡片')
WHERE partition_date = '{today_str}'
when transaction_type in ('newdata') then array('保量卡片')
when transaction_type in ('hotspot_feed') then array('hotspot_feed','合计')
--马甲账号/模特用户
when transaction_type in ('aistragegy') then array('新用户AI帖优先','合计')
UNION ALL
when transaction_type in ('excestragegy') then array('新用户精华帖优先','合计')
SELECT user_id
when transaction_type in ('FIXEDSTRATEGY') then array('新氧新用户策略一','合计')
FROM ml.ml_c_ct_ui_user_dimen_d
when transaction_type in ('FIXEDSTRATEGY_VIDEO') then array('新氧新用户策略二','合计')
WHERE partition_day = '{today_str}'
when transaction_type like 'deeplink%' then array('deeplink策略','合计')
AND (is_puppet = 'true' or is_classifyuser = 'true')
end AS recommend_type,
card_id,
UNION ALL
app_session_id
--公司内网覆盖用户
from online.ml_community_precise_exposure_detail
select distinct user_id
WHERE partition_date={partition_day}
from dim.dim_device_user_staff
AND action in ('page_precise_exposure','home_choiceness_card_exposure') --7745版本action改为page_precise_exposure
AND is_exposure = '1' ----精准曝光
UNION ALL
AND page_name ='home'
--登陆过医生设备
AND tab_name = '精选'
SELECT distinct t1.user_id
AND (transaction_type in ('-1','smr','hotspot','pgc','newdata','hotspot_feed','aistragegy','excestragegy','FIXEDSTRATEGY','FIXEDSTRATEGY_VIDEO')
FROM
or transaction_type like '%ctr' or transaction_type like '%cvr' or transaction_type like 'deeplink%')
(
AND card_content_type in ('qa','diary','user_post','answer','special_pool')
SELECT user_id, v.device_id as device_id
group by partition_date,
FROM online.ml_user_history_detail
case when card_content_type in ('qa','answer') then 'qa'
LATERAL VIEW EXPLODE(device_history_list) v AS device_id
when card_content_type in ('special_pool') then 'special' else card_content_type end,
WHERE partition_date = '{today_str}'
cl_id,
) t1
CASE when transaction_type in ('fmctr','samecity_fmctr') then array('fmctr','合计')
JOIN
when 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预估','合计')
SELECT device_id
when transaction_type in ('high_quality_ctr') then array('high_quality_ctr','合计')
FROM online.ml_device_history_detail
WHEN transaction_type like '%cvr' THEN array('cvr预估','合计')
WHERE partition_date = '{today_str}'
WHEN transaction_type in ('-1','smr') THEN array('smr','合计')
AND is_login_doctor = '1'
when transaction_type in ('pgc','hotspot') then array('热点卡片')
) t2
when transaction_type in ('newdata') then array('保量卡片')
ON t1.device_id = t2.device_id
when transaction_type in ('hotspot_feed') then array('hotspot_feed','合计')
)t2
when transaction_type in ('aistragegy') then array('新用户AI帖优先','合计')
on t1.user_id=t2.user_id
when transaction_type in ('excestragegy') then array('新用户精华帖优先','合计')
group by partition_date,device_id
when transaction_type in ('FIXEDSTRATEGY') then array('新氧新用户策略一','合计')
)dev
when transaction_type in ('FIXEDSTRATEGY_VIDEO') then array('新氧新用户策略二','合计')
on t2.device_id=dev.device_id
when transaction_type like 'deeplink%' then array('deeplink策略','合计') end,