Commit 7ac77265 authored by litaolemo's avatar litaolemo

update

parent 0d0f4e17
......@@ -154,32 +154,60 @@ print(huidu_device_id_sql)
huidu_device_id_df = spark.sql(huidu_device_id_sql)
huidu_device_id_df.createOrReplaceTempView("dev_view")
sql_search_ctr = r"""
SELECT
count(distinct (a.cl_id))
SELECT card_name,count(card_name)
-- click.partition_date as partition_date
-- ,active_type
-- ,device_os_type
-- ,channel
-- ,count(click.cl_id) as all_search_click_pv_724
-- ,count(distinct click.cl_id) as all_search_click_uv_724
FROM
(select device_id from dev_view) t1 left join
(
SELECT
cl_id,
card_id,
app_session_id,
transaction_type
from online.ml_community_precise_exposure_detail
WHERE partition_date>= '${today_str}'
AND action in ('page_precise_exposure','home_choiceness_card_exposure') --7745版本action改为page_precise_exposure
AND is_exposure = '1' ----精准曝光
AND page_name ='home'
AND tab_name = '精选'
AND (transaction_type in ('-1','smr','hotspot','pgc','newdata','hotspot_feed','aistragegy','excestragegy','FIXEDSTRATEGY','FIXEDSTRATEGY_VIDEO','high_quality_fmctr')
or transaction_type like '%ctr' or transaction_type like '%cvr' or transaction_type like 'deeplink%')
AND card_content_type in ('user_post')
group by
cl_id,
transaction_type,
card_id,
app_session_id
)a on t1.device_id = a.cl_id
""".format(today_str='20200926')
SELECT cl_id,partition_date,action,params['page_name'] as page_name,'' as input_type,app_version,params['card_name'] as card_name
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= '{start_date}'
AND partition_date < '{end_date}'
AND action = 'on_click_navbar_search'
AND (int(split(app_version,'\\.')[0]) = 7 AND int(split(app_version,'\\.')[1]) >= 24)
UNION all
SELECT cl_id,partition_date,action,params['page_name'] as page_name,params['input_type'] as input_type,app_version,params['card_name'] as card_name
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= '{start_date}'
AND partition_date < '{end_date}'
AND action = 'do_search'
AND params['input_type'] = '详情页默认词'
union all
SELECT cl_id,partition_date,action,'home' as page_name,'首页-猜你喜欢' as input_type,app_version,params['card_name'] as card_name
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= '{start_date}'
AND partition_date < '{end_date}'
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,action,params['page_name'] as page_name,'美购首页-大家都在搜' as input_type,app_version,params['card_name'] as card_name
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= '{start_date}'
AND partition_date < '{end_date}'
AND action = 'on_click_card'
AND params['page_name']='welfare_home'
AND params['card_type'] ='search_word'
AND params['in_page_pos']='大家都在搜'
union all
SELECT cl_id,partition_date,action,params['page_name'] as page_name,'高亮词' as input_type,app_version,params['card_name'] as card_name
FROM online.bl_hdfs_maidian_updates
WHERE partition_date >= '{start_date}'
AND partition_date < '{end_date}'
AND action = 'on_click_card'
AND params['card_type'] ='highlight_word'
) group by card_name
""".format(start_date='20201024',partition_date='20201025')
print(sql_search_ctr)
search_ctr_df = spark.sql(sql_search_ctr)
......
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