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