Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
search-model-data
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
田川
search-model-data
Commits
9d1634b7
Commit
9d1634b7
authored
Nov 19, 2021
by
xupeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
废弃search_data_cross_feature_user_product_buy,合并到用户商品交叉特征 user_product_feature.sh
parent
d10edc25
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
48 deletions
+68
-48
create_cross_feature_user_product_buy.sql
src/main/scripts/cross_feature/user_product/create_cross_feature_user_product_buy.sql
+11
-11
insert_cross_feature_user_product_buy.sql
src/main/scripts/cross_feature/user_product/insert_cross_feature_user_product_buy.sql
+47
-27
user_product_buy_feature.sh
src/main/scripts/cross_feature/user_product/user_product_buy_feature.sh
+10
-10
No files found.
src/main/scripts/cross_feature/user_product/create_cross_feature_user_product_buy.sql
View file @
9d1634b7
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
src/main/scripts/cross_feature/user_product/insert_cross_feature_user_product_buy.sql
View file @
9d1634b7
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
--
--
--
--
--
--
--
--
--
--
--
--
src/main/scripts/cross_feature/user_product/user_product_buy_feature.sh
View file @
9d1634b7
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
#
#
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment