AND first_channel_source_type not like 'promotion\_jf\_%'
) a
)t1
JOIN
( --新首页卡片曝光
SELECT concat_ws('-',substr(partition_date,1,4),substr(partition_date,5,2),substr(partition_date,7,2)) as partition_date
,cl_id
,case when card_content_type in ('diary','topic') and (get_json_object(exposure_card,'$.redirect_content_type') not in ('service') or get_json_object(exposure_card,'$.redirect_content_type') is null) then '日记'
when card_content_type in ('question','answer','qa') and (get_json_object(exposure_card,'$.redirect_content_type') not in ('service') or get_json_object(exposure_card,'$.redirect_content_type') is null) then '问答'
when card_content_type in ('user_post','doctor_post') and (get_json_object(exposure_card,'$.redirect_content_type') not in ('service') or get_json_object(exposure_card,'$.redirect_content_type') is null) then '帖子'
when card_content_type in ('service') and (get_json_object(exposure_card,'$.redirect_content_type') not in ('service') or get_json_object(exposure_card,'$.redirect_content_type') is null) then '商品'
when get_json_object(exposure_card,'$.redirect_content_type')='service' then '商品评价' END as card_content_type
,case when get_json_object(exposure_card,'$.is_cpc')=1 then '是' else '否' end as is_cpc
,case when get_json_object(exposure_card,'$.redirect_content_type')='service' then get_json_object(exposure_card,'$.redirect_id') else card_id end as card_id
,count(distinct app_session_id) as exp_pv
FROM online.ml_community_precise_exposure_detail
where partition_date>='{}' and partition_date<=regexp_replace(DATE_SUB(current_date,1) ,'-','')
and action in ('page_precise_exposure','home_choiceness_card_exposure')
and is_exposure='1'
and page_name='new_community_home'
and tab_name='精选'
and card_type in ('card','video')
and card_content_type in ('diary','question','answer','qa','topic','user_post','doctor_post','service')
group by concat_ws('-',substr(partition_date,1,4),substr(partition_date,5,2),substr(partition_date,7,2))
,cl_id
,case when card_content_type in ('diary','topic') and (get_json_object(exposure_card,'$.redirect_content_type') not in ('service') or get_json_object(exposure_card,'$.redirect_content_type') is null) then '日记'
when card_content_type in ('question','answer','qa') and (get_json_object(exposure_card,'$.redirect_content_type') not in ('service') or get_json_object(exposure_card,'$.redirect_content_type') is null) then '问答'
when card_content_type in ('user_post','doctor_post') and (get_json_object(exposure_card,'$.redirect_content_type') not in ('service') or get_json_object(exposure_card,'$.redirect_content_type') is null) then '帖子'
when card_content_type in ('service') and (get_json_object(exposure_card,'$.redirect_content_type') not in ('service') or get_json_object(exposure_card,'$.redirect_content_type') is null) then '商品'
when get_json_object(exposure_card,'$.redirect_content_type')='service' then '商品评价' END
,case when get_json_object(exposure_card,'$.is_cpc')=1 then '是' else '否' end
,case when get_json_object(exposure_card,'$.redirect_content_type')='service' then get_json_object(exposure_card,'$.redirect_id') else card_id end
)t2
on t2.partition_date=t1.partition_date and t2.cl_id=t1.device_id
LEFT JOIN
( --首页卡片点击
SELECT concat_ws('-',substr(partition_date,1,4),substr(partition_date,5,2),substr(partition_date,7,2)) as partition_date
,cl_id
,case when params['card_content_type'] in ('diary','topic') and (params['redirect_content_type'] not in ('service') or params['redirect_content_type'] is null) then '日记'
when params['card_content_type'] in ('question','answer','qa') and (params['redirect_content_type'] not in ('service') or params['redirect_content_type'] is null) then '问答'
when params['card_content_type'] in ('user_post','doctor_post') and (params['redirect_content_type'] not in ('service') or params['redirect_content_type'] is null) then '帖子'
when params['card_content_type'] in ('service') and (params['redirect_content_type'] not in ('service') or params['redirect_content_type'] is null) then '商品'
when params['redirect_content_type']='service' then '商品评价' END as card_content_type
,case when params['is_cpc']=1 then '是' else '否' end as is_cpc
,case when params['redirect_content_type']='service' then params['redirect_id'] else params['card_id'] end as card_id
,count(distinct time_str) as click_pv
FROM online.bl_hdfs_maidian_updates
where partition_date>='{}' and partition_date<=regexp_replace(DATE_SUB(current_date,1) ,'-','')
and action='on_click_card'
and page_name='new_community_home'
and params['tab_name']='精选'
and params['card_type'] in ('card','video')
and params['card_content_type'] in ('diary','question','answer','qa','topic','user_post','doctor_post','service')
group by concat_ws('-',substr(partition_date,1,4),substr(partition_date,5,2),substr(partition_date,7,2))
,cl_id
,case when params['card_content_type'] in ('diary','topic') and (params['redirect_content_type'] not in ('service') or params['redirect_content_type'] is null) then '日记'
when params['card_content_type'] in ('question','answer','qa') and (params['redirect_content_type'] not in ('service') or params['redirect_content_type'] is null) then '问答'
when params['card_content_type'] in ('user_post','doctor_post') and (params['redirect_content_type'] not in ('service') or params['redirect_content_type'] is null) then '帖子'
when params['card_content_type'] in ('service') and (params['redirect_content_type'] not in ('service') or params['redirect_content_type'] is null) then '商品'
when params['redirect_content_type']='service' then '商品评价' END
,case when params['is_cpc']=1 then '是' else '否' end
,case when params['redirect_content_type']='service' then params['redirect_id'] else params['card_id'] end
)t3
on t3.partition_date=t2.partition_date and t3.cl_id=t2.cl_id and t3.card_content_type=t2.card_content_type and t3.card_id=t2.card_id
LEFT JOIN
( --去除黑名单
select distinct device_id
from ML.ML_D_CT_DV_DEVICECLEAN_DIMEN_D
where PARTITION_DAY =regexp_replace(DATE_SUB(current_date,1) ,'-','')
AND is_abnormal_device = 'true'
)t5
on t5.device_id=t3.cl_id
WHERE t5.device_id is null
group by t1.partition_date
,array(device_os_type,'合计')
,array(active_type,'合计')
,array(t2.card_content_type,'合计')
,array(t2.is_cpc,'合计')
,t1.device_id
)t
lateral view explode(t.device_os_type ) a as device_os_type
lateral view explode(t.active_type ) b as active_type
lateral view explode(t.card_content_type ) d as card_content_type
# NVL(ROUND((navbar_search+highlight_word+self_welfare_card+recommend_welfare_card+recommend_content_card*0.2+transfer_card+video_consultation)/card_exposure,5),0) as recommend_ctr,
# NVL(ROUND(card_click/card_exposure,5),0) as click_ctr,
# NVL(ROUND((navbar_search+highlight_word+self_welfare_card+recommend_welfare_card+recommend_content_card*0.2+transfer_card+video_consultation)/card_click,5),0) as second_jump_ctr ,
# NVL(ROUND(page_pv_20/page_pv,5),0) as page_pv_20_percent