Commit 10db9cdb authored by litaolemo's avatar litaolemo

update

parent c94f9912
...@@ -87,110 +87,122 @@ spark.sql("CREATE TEMPORARY FUNCTION arrayMerge AS 'com.gmei.hive.common.udf.UDF ...@@ -87,110 +87,122 @@ spark.sql("CREATE TEMPORARY FUNCTION arrayMerge AS 'com.gmei.hive.common.udf.UDF
# huidu_device_id_df = spark.sql(huidu_device_id_sql) # huidu_device_id_df = spark.sql(huidu_device_id_sql)
# huidu_device_id_df.createOrReplaceTempView("dev_view") # huidu_device_id_df.createOrReplaceTempView("dev_view")
sql_search_ctr = r""" sql_search_ctr = r"""
SELECT query SELECT partition_date,
, all_search_uv as all_search_uv --全部搜索uv cl_id,
, t3.all_search_pv as all_search_pv --全部搜索pv count(distinct app_session_id) as session_pv0
FROM ( FROM
--搜索pvuv (
SELECT query SELECT partition_date,
, count(click.cl_id) as all_search_pv cl_id,
, count(distinct click.cl_id) as all_search_uv case when params['card_content_type'] in ('qa','answer') then 'qa'
FROM ( when params['card_content_type'] in ('special_pool') then 'special' else params['card_content_type'] end as card_content_type,
SELECT cl_id, CASE when params['transaction_type'] in ('fmctr','samecity_fmctr') then array('fmctr','合计')
partition_date, when params['transaction_type'] in ('high_quality_fmctr') then array('high_quality_fmctr','合计')
action, WHEN (params['transaction_type'] like '%ctr' and params['transaction_type'] not in ('high_quality_ctr','high_quality_fmctr','fmctr','samecity_fmctr')) THEN array('ctr预估','合计')
params['page_name'] as page_name, when params['transaction_type'] in ('high_quality_ctr') then array('high_quality_ctr','合计')
params['input_type'] as input_type, WHEN params['transaction_type'] like '%cvr' THEN array('cvr预估','合计')
app_version, WHEN params['transaction_type'] in ('-1','smr') THEN array('smr','合计')
params['query'] as query when params['transaction_type'] in ('pgc','hotspot') then array('热点卡片')
FROM online.bl_hdfs_maidian_updates when params['transaction_type'] in ('newdata') then array('保量卡片')
WHERE partition_date >= '{start_date}' when params['transaction_type'] in ('hotspot_feed') then array('hotspot_feed','合计')
AND partition_date < '{end_date}' when params['transaction_type'] in ('aistragegy') then array('新用户AI帖优先','合计')
AND ((action = 'do_search' AND params['input_type'] <> 'everyone_watch') or when params['transaction_type'] in ('excestragegy') then array('新用户精华帖优先','合计')
action = 'search_result_click_search') when params['transaction_type'] in ('FIXEDSTRATEGY') then array('新氧新用户策略一','合计')
when params['transaction_type'] in ('FIXEDSTRATEGY_VIDEO') then array('新氧新用户策略二','合计')
UNION all when params['transaction_type'] like 'deeplink%' then array('deeplink策略','合计')
SELECT cl_id, end AS recommend_type,
partition_date, params['card_id'] as card_id,
action, app_session_id
params['page_name'] as page_name, from online.bl_hdfs_maidian_updates
params['input_type'] as input_type, WHERE partition_date={partition_day}
app_version, AND action='on_click_card'
params['query'] as query AND params['page_name'] ='home'
FROM online.bl_hdfs_maidian_updates AND params['tab_name'] = '精选'
WHERE partition_date >= '{start_date}' AND (params['transaction_type'] in ('-1','smr','hotspot','pgc','newdata','hotspot_feed','aistragegy','excestragegy','FIXEDSTRATEGY','FIXEDSTRATEGY_VIDEO')
AND partition_date < '{end_date}' or params['transaction_type'] like '%ctr' or params['transaction_type'] like '%cvr' or params['transaction_type'] like 'deeplink%')
AND action = 'do_search' AND params['card_content_type'] in ('qa','diary','user_post','answer','special_pool')
and params['input_type'] = 'everyone_watch' GROUP BY partition_date,
and params['tab'] = '精选' cl_id,
and page_name = 'home' case when params['card_content_type'] in ('qa','answer') then 'qa'
AND params['query'] not in ('AI测颜值', 'AI测肤质') --这两个词不跳转搜索结果页 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','合计')
union all when params['transaction_type'] in ('high_quality_fmctr') then array('high_quality_fmctr','合计')
SELECT cl_id, WHEN (params['transaction_type'] like '%ctr' and params['transaction_type'] not in ('high_quality_ctr','high_quality_fmctr','fmctr','samecity_fmctr')) THEN array('ctr预估','合计')
partition_date, when params['transaction_type'] in ('high_quality_ctr') then array('high_quality_ctr','合计')
action, WHEN params['transaction_type'] like '%cvr' THEN array('cvr预估','合计')
'search_home' as page_name, WHEN params['transaction_type'] in ('-1','smr') THEN array('smr','合计')
'' as input_type, when params['transaction_type'] in ('pgc','hotspot') then array('热点卡片')
app_version, when params['transaction_type'] in ('newdata') then array('保量卡片')
params['query'] as query when params['transaction_type'] in ('hotspot_feed') then array('hotspot_feed','合计')
FROM online.bl_hdfs_maidian_updates when params['transaction_type'] in ('aistragegy') then array('新用户AI帖优先','合计')
WHERE partition_date >= '{start_date}' when params['transaction_type'] in ('excestragegy') then array('新用户精华帖优先','合计')
AND partition_date < '{end_date}' when params['transaction_type'] in ('FIXEDSTRATEGY') then array('新氧新用户策略一','合计')
AND action = 'on_click_card' when params['transaction_type'] in ('FIXEDSTRATEGY_VIDEO') then array('新氧新用户策略二','合计')
AND params['page_name'] = 'search_home' when params['transaction_type'] like 'deeplink%' then array('deeplink策略','合计') end,
params['card_id'],
union all app_session_id
SELECT cl_id, )a
partition_date, LATERAL VIEW explode (a.recommend_type) v as recommend_type
action, group by partition_date,card_content_type,cl_id,v.recommend_type,card_id having session_pv0 >0
'home' as page_name,
'首页-猜你喜欢' as input_type, UNION
app_version, SELECT partition_date,
params['card_name'] as query cl_id,
FROM online.bl_hdfs_maidian_updates count(distinct card_id) as session_pv0
WHERE partition_date >= '{start_date}' FROM
AND partition_date < '{end_date}' (SELECT partition_date,
AND action = 'on_click_card' cl_id,
AND params['in_page_pos'] = '猜你喜欢' case when card_content_type in ('qa','answer') then 'qa'
--AND params['tab_name']='精选' when card_content_type in ('special_pool') then 'special' else card_content_type end as card_content_type,
AND params['card_type'] = 'search_word' CASE when transaction_type in ('fmctr','samecity_fmctr') then array('fmctr','合计')
AND params['card_name'] not in ('AI测颜值', 'AI测肤质') --这两个词不跳转搜索结果页 when transaction_type in ('high_quality_fmctr') then array('high_quality_fmctr','合计')
--AND page_name='home' android的page_name为空 WHEN (transaction_type like '%ctr' and 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','合计')
union all WHEN transaction_type like '%cvr' THEN array('cvr预估','合计')
SELECT cl_id, WHEN transaction_type in ('-1','smr') THEN array('smr','合计')
partition_date, when transaction_type in ('pgc','hotspot') then array('热点卡片')
action, when transaction_type in ('newdata') then array('保量卡片')
params['page_name'] as page_name, when transaction_type in ('hotspot_feed') then array('hotspot_feed','合计')
'美购首页-大家都在搜' as input_type, when transaction_type in ('aistragegy') then array('新用户AI帖优先','合计')
app_version, when transaction_type in ('excestragegy') then array('新用户精华帖优先','合计')
params['card_name'] as query when transaction_type in ('FIXEDSTRATEGY') then array('新氧新用户策略一','合计')
FROM online.bl_hdfs_maidian_updates when transaction_type in ('FIXEDSTRATEGY_VIDEO') then array('新氧新用户策略二','合计')
WHERE partition_date >= '{start_date}' when transaction_type like 'deeplink%' then array('deeplink策略','合计')
AND partition_date < '{end_date}' end AS recommend_type,
AND action = 'on_click_card' card_id,
AND params['page_name'] = 'welfare_home' app_session_id
AND params['card_type'] = 'search_word' from online.ml_community_precise_exposure_detail
AND params['in_page_pos'] = '大家都在搜' WHERE partition_date={partition_day}
AND action in ('page_precise_exposure','home_choiceness_card_exposure') --7745版本action改为page_precise_exposure
union all AND is_exposure = '1' ----精准曝光
SELECT cl_id, AND page_name ='home'
partition_date, AND tab_name = '精选'
action, AND (transaction_type in ('-1','smr','hotspot','pgc','newdata','hotspot_feed','aistragegy','excestragegy','FIXEDSTRATEGY','FIXEDSTRATEGY_VIDEO')
params['page_name'] as page_name, or transaction_type like '%ctr' or transaction_type like '%cvr' or transaction_type like 'deeplink%')
'高亮词' as input_type, AND card_content_type in ('qa','diary','user_post','answer','special_pool')
app_version, group by partition_date,
params['card_name'] as query case when card_content_type in ('qa','answer') then 'qa'
FROM online.bl_hdfs_maidian_updates when card_content_type in ('special_pool') then 'special' else card_content_type end,
WHERE partition_date >= '{start_date}' cl_id,
AND partition_date < '{end_date}' CASE when transaction_type in ('fmctr','samecity_fmctr') then array('fmctr','合计')
AND action = 'on_click_card' when transaction_type in ('high_quality_fmctr') then array('high_quality_fmctr','合计')
AND params['card_type'] = 'highlight_word' WHEN (transaction_type like '%ctr' and transaction_type not in ('high_quality_ctr','high_quality_fmctr','fmctr','samecity_fmctr')) THEN array('ctr预估','合计')
) click when transaction_type in ('high_quality_ctr') then array('high_quality_ctr','合计')
WHEN transaction_type like '%cvr' THEN array('cvr预估','合计')
GROUP BY query WHEN transaction_type in ('-1','smr') THEN array('smr','合计')
) t3 order by all_search_uv asc when transaction_type in ('pgc','hotspot') then array('热点卡片')
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帖优先','合计')
when transaction_type in ('excestragegy') then array('新用户精华帖优先','合计')
when transaction_type in ('FIXEDSTRATEGY') then array('新氧新用户策略一','合计')
when transaction_type in ('FIXEDSTRATEGY_VIDEO') then array('新氧新用户策略二','合计')
when transaction_type like 'deeplink%' then array('deeplink策略','合计') end,
card_id,
app_session_id
)a
LATERAL VIEW explode (a.recommend_type) v as recommend_type
group by partition_date,cl_id having session_pv0 >= 4
""".format(start_date='20201017',end_date='20201116') """.format(start_date='20201017',end_date='20201116')
......
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