Commit 9d1634b7 by xupeng

废弃search_data_cross_feature_user_product_buy,合并到用户商品交叉特征 user_product_feature.sh

parent d10edc25
create external table if not exists secoo_search.search_data_cross_feature_user_product_buy -- create external table if not exists secoo_search.search_data_cross_feature_user_product_buy
( -- (
device_id string comment '设备id', -- device_id string comment '设备id',
product_id string comment '商品id', -- product_id string comment '商品id',
category2_id string comment '二级类目id', -- category2_id string comment '二级类目id',
cate_2_price_level string comment '商品二级类目价格段1-10', -- cate_2_price_level string comment '商品二级类目价格段1-10',
user_product_buy_is_match string comment '用户购买商品二级类目价格等级是否匹配商品二级类目价格等级:1/0', -- user_product_buy_is_match string comment '用户购买商品二级类目价格等级是否匹配商品二级类目价格等级:1/0',
user_product_buy_price_level string comment '用户购买商品二级类目价格等级是否匹配商品二级类目价格等级:price_level/0' -- user_product_buy_price_level string comment '用户购买商品二级类目价格等级是否匹配商品二级类目价格等级:price_level/0'
) comment '用户商品购买交叉特征' -- ) comment '用户商品购买交叉特征'
partitioned by (p_day date comment '分区日期'); -- partitioned by (p_day date comment '分区日期');
\ No newline at end of file \ No newline at end of file
insert overwrite table secoo_search.search_data_cross_feature_user_product_buy partition(p_day=${yesterday}) -- insert overwrite table secoo_search.search_data_cross_feature_user_product_buy partition(p_day=${yesterday})
select -- select
UPPER(T1.uuid) as device_id, -- T2.uuid as device_id,
T1.product_id as product_id, -- T0.product_id as product_id,
T1.category_id_2 as category2_id, -- T0.category_id_2 as category2_id,
T1.buy_sku_cat2_price_level as cate_2_price_level, -- T1.cate_2_price_level as cate_2_price_level,
case -- case
when T1.buy_sku_cat2_price_level = T2.cate_2_price_level then 1 -- when T2.buy_sku_cat2_price_level = T1.cate_2_price_level then 1
else 0 -- else 0
end as user_product_buy_is_match, -- end as user_product_buy_is_match,
case -- T2.buy_sku_cat2_price_level as user_product_buy_price_level
when T1.buy_sku_cat2_price_level = T2.cate_2_price_level then T1.buy_sku_cat2_price_level -- from
else 0 -- (select
end as user_product_buy_price_level -- product_id as product_id,
from secoo_app.app_search_uuid_sku_price_level T1 -- main_id
left join -- from secoo_fact.fact_search_product_wide_p_day
(select -- where p_day = ${yesterday}
W.product_id as product_id, -- ) T0
split(W.category_org_code,'_')[2] as category_id_2, -- left join (
P.cate_2_price_level as cate_2_price_level -- select
from secoo_fact.fact_search_product_wide_p_day W -- product_main_id,
join secoo_fact.fact_search_product_55_30d_click_product_p_day P on W.main_id = P.product_main_id and P.p_day = ${yesterday} -- category_id_2,
where W.p_day = ${yesterday} -- cate_2_price_level
) T2 on T1.product_id = T2.product_id -- from secoo_fact.fact_search_product_55_30d_click_product_p_day
where T1.p_day = ${yesterday} -- where p_day = ${yesterday}
-- ) T1 on T0.main_id = T1.product_main_id
-- left join (
-- select
-- uuid,
-- category_id_2,
-- max(buy_sku_cat2_price_level) as buy_sku_cat2_price_level
-- from secoo_app.app_search_uuid_sku_price_level
-- where p_day = ${yesterday}
-- group by uuid, category_id_2
-- ) T2 on T0.category_id_2 = T2.category_id_2
--
--
--
--
--
--
--
--
--
--
--
--
work_dir="/home/pcsjob/search/search-model-data/src/main/scripts/cross_feature/user_product/" #work_dir="/home/pcsjob/search/search-model-data/src/main/scripts/cross_feature/user_product/"
# 用户商品交叉特征-购买 ## 用户商品交叉特征-购买
delta_day=1 #delta_day=1
today_param=$1 #today_param=$1
yesterday=`date -d "${today_param} -$delta_day day" "+%Y-%m-%d"` #yesterday=`date -d "${today_param} -$delta_day day" "+%Y-%m-%d"`
#
hive -f "$work_dir"create_cross_feature_user_product_buy.sql #hive -f "$work_dir"create_cross_feature_user_product_buy.sql
hive --hivevar yesterday="'${yesterday}'" -f "$work_dir"insert_cross_feature_user_product_buy.sql #hive --hivevar yesterday="'${yesterday}'" -f "$work_dir"insert_cross_feature_user_product_buy.sql
#
#
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