Commit f5e6a68e by zhaoyanchao

商品特征数据,推荐的原有特征及 搜索的销量相关的特征

parent 48ea4f19
-- 商品特征表
create external table if not exists secoo_search.search_data_product_feature
(
product_id string comment '商品id',
is_brand_top_100 string comment '是否是百大品牌',
product_popularity string comment '浏览、收藏、加购综合算的热度值',
is_member_product string comment '是否会员商品',
is_special_product string comment '是否是特例品',
is_new_customer_product string comment '是否新客商品',
is_new_product string comment '是否是新品',
is_new_style string comment '是否是新款',
is_self_operating string comment '是否自营品',
product_level string comment '商品等级',
is_promotion_product string comment '是否是促销商品',
gender string comment '性别',
product_brand string comment '商品的品牌',
product_category string comment '商品的品类',
product_price_level string comment '商品价格(需要离散化)',
ctr_android_3days string comment '安卓系统下商品3天的CTR',
ctr_android_7days string comment '安卓系统下商品7天的CTR',
ctr_android_30days string comment '安卓系统下商品30天的CTR',
ctr_ios_3days string comment 'ios系统下商品3天的CTR',
ctr_ios_7days string comment 'ios系统下商品7天的CTR',
ctr_ios_30days string comment 'ios系统下商品30天的CTR',
ctr_3days string comment '全部系统下商品3天的CTR',
ctr_7days string comment '全部系统下商品7天的CTR',
ctr_30days string comment '全部系统下商品30天的CTR',
favorite_android_3days string comment '安卓系统下商品3天的收藏',
favorite_android_7days string comment '安卓系统下商品7天的收藏',
favorite_android_30days string comment '安卓系统下商品30天的收藏',
favorite_ios_3days string comment 'ios系统下商品3天的收藏',
favorite_ios_7days string comment 'ios系统下商品7天的收藏',
favorite_ios_30days string comment 'ios系统下商品30天的收藏',
favorite_3days string comment '全部系统下商品3天的收藏',
favorite_7days string comment '全部系统下商品7天的收藏',
favorite_30days string comment '全部系统下商品30天的收藏',
add_cart_android_3days string comment '安卓系统下商品3天的加购',
add_cart_android_7days string comment '安卓系统下商品7天的加购',
add_cart_android_30days string comment '安卓系统下商品30天的加购',
add_cart_ios_3days string comment 'ios系统下商品3天的加购',
add_cart_ios_7days string comment 'ios系统下商品7天的加购',
add_cart_ios_30days string comment 'ios系统下商品30天的加购',
add_cart_3days string comment '全部系统下商品3天的加购',
add_cart_7days string comment '全部系统下商品7天的加购',
add_cart_30days string comment '全部系统下商品30天的加购',
area_type tinyint comment '货源地,(0大陆 1香港 2美国 3日本 4意大利)',
sale_qty_180 bigint comment '前180天至今销售数量',
sale_qty_90 bigint comment '前90天至今销售数量',
sale_qty_30 bigint comment '前30天至今销售数量',
sale_qty_15 bigint comment '前15天至今销售数量'
) comment '商品特征'
partitioned by (
p_day date comment '分区日期'
)
stored as parquet;
-- 写入商品特征表数据
insert overwrite table secoo_search.search_data_product_feature partition(p_day=date'2021-05-06')
select
R.product_id,
R.isbrand100 as is_brand_top_100,
R.productpopularity as product_popularity,
R.ismemberproduct as is_member_product ,
R.isspecialproduct as is_special_product,
R.isnewcustomerproduct as is_new_customer_product,
R.isnewproduct as is_new_product,
R.isnewstyle as is_new_style,
R.isselfoperating as is_self_operating,
R.productlevel as product_level,
R.ispromotionproduct as is_promotion_product,
R.prodgender as gender,
R.productbrand as product_brand,
R.productcategory as product_category,
R.productpricelevel as product_price_level,
R.3daysandroidctr as ctr_android_3days,
R.7daysandroidctr as ctr_android_7days,
R.30daysandroidctr as ctr_android_30days,
R.3daysiosctr as ctr_ios_3days,
R.7daysiosctr as ctr_ios_7days,
R.30daysiosctr as ctr_ios_30days,
R.3daysctr as ctr_3days,
R.7daysctr as ctr_7days,
R.30daysctr as ctr_30days,
R.3daysandroidfavorite as favorite_android_3days,
R.7daysandroidfavorite as favorite_android_7days,
R.30daysandroidfavorite as favorite_android_30days,
R.3daysiosfavorite as favorite_ios_3days,
R.7daysiosfavorite as favorite_ios_7days,
R.30daysiosfavorite as favorite_ios_30days,
R.3daysfavorite as favorite_3days,
R.7daysfavorite as favorite_7days,
R.30daysfavorite as favorite_30days,
R.3daysandroidaddcart as add_cart_android_3days,
R.7daysandroidaddcart as add_cart_android_7days,
R.30daysandroidaddcart as add_cart_android_30days,
R.3daysiosaddcart as add_cart_ios_3days,
R.7daysiosaddcart as add_cart_ios_7days,
R.30daysiosaddcart as add_cart_ios_30days,
R.3daysaddcart as add_cart_3days,
R.7daysaddcart as add_cart_7days,
R.30daysaddcart as add_cart_30days,
W.area_type,
W.sale_qty_180,
W.sale_qty_90,
W.sale_qty_30,
W.sale_qty_15
from secoo_rcmd_features.productFeatures_2021_04_23 R
left join secoo_fact.fact_search_product_wide_p_day W
on R.product_id = cast(W.product_id AS string) and W.p_day = '2021-05-06';
# 如果无表,建表
hive -f create_search_product_feature_table.sql
hive -f insert_search_product_feature.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