Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
Amazon-Selection-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
abel_cjy
Amazon-Selection-Data
Commits
f9621843
Commit
f9621843
authored
Oct 29, 2026
by
chenyuanjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
流量选品-月/周隐藏分类修复
parent
f17ce091
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
11 deletions
+12
-11
dwt_flow_asin.py
Pyspark_job/dwt/dwt_flow_asin.py
+6
-6
dwt_flow_asin_week.py
Pyspark_job/dwt/dwt_flow_asin_week.py
+6
-5
No files found.
Pyspark_job/dwt/dwt_flow_asin.py
View file @
f9621843
...
@@ -33,6 +33,7 @@ from pyspark.storagelevel import StorageLevel
...
@@ -33,6 +33,7 @@ from pyspark.storagelevel import StorageLevel
from
pyspark.sql.types
import
*
from
pyspark.sql.types
import
*
from
utils.DorisHelper
import
DorisHelper
from
utils.DorisHelper
import
DorisHelper
from
yswg_utils.common_udf
import
resolve_asin_jump
from
yswg_utils.common_udf
import
resolve_asin_jump
from
yswg_utils.common_df
import
get_first_id_from_category_desc_df
class
DwtFlowAsin
(
Templates
):
class
DwtFlowAsin
(
Templates
):
...
@@ -639,12 +640,11 @@ class DwtFlowAsin(Templates):
...
@@ -639,12 +640,11 @@ class DwtFlowAsin(Templates):
"desc_category_first_name"
,
"desc_category_first_name"
,
F
.
lower
(
F
.
trim
(
F
.
split
(
F
.
col
(
"asin_category_desc"
),
"›"
)
.
getItem
(
0
)))
F
.
lower
(
F
.
trim
(
F
.
split
(
F
.
col
(
"asin_category_desc"
),
"›"
)
.
getItem
(
0
)))
)
)
# 读取 Hive 分类维表,获取分类名称与ID的对应关系
# 获取一级分类名称与ID的对应关系(与30天流程一致)
sql_dim
=
f
"""
df_bsr_category
=
F
.
broadcast
(
get_first_id_from_category_desc_df
(
self
.
site_name
,
self
.
spark
)
.
select
(
select lower(trim(en_name)) as desc_category_first_name, category_first_id as desc_category_first_id
F
.
lower
(
F
.
col
(
'category_first_name'
))
.
alias
(
'desc_category_first_name'
),
from dim_bsr_category_tree where site_name = '{self.site_name}' and category_parent_id = 0 and leaf_node = 2
F
.
col
(
'category_first_id'
)
.
alias
(
'desc_category_first_id'
)
"""
))
df_bsr_category
=
F
.
broadcast
(
self
.
spark
.
sql
(
sqlQuery
=
sql_dim
))
# join 补充分类ID
# join 补充分类ID
self
.
df_asin_detail
=
self
.
df_asin_detail
.
join
(
df_bsr_category
,
on
=
[
'desc_category_first_name'
],
how
=
'left'
)
self
.
df_asin_detail
=
self
.
df_asin_detail
.
join
(
df_bsr_category
,
on
=
[
'desc_category_first_name'
],
how
=
'left'
)
# 两个分类ID均在过滤列表中才标记为1
# 两个分类ID均在过滤列表中才标记为1
...
...
Pyspark_job/dwt/dwt_flow_asin_week.py
View file @
f9621843
...
@@ -32,6 +32,7 @@ from utils.hdfs_utils import HdfsUtils
...
@@ -32,6 +32,7 @@ from utils.hdfs_utils import HdfsUtils
from
pyspark.storagelevel
import
StorageLevel
from
pyspark.storagelevel
import
StorageLevel
from
pyspark.sql.types
import
*
from
pyspark.sql.types
import
*
from
yswg_utils.common_udf
import
resolve_asin_jump
from
yswg_utils.common_udf
import
resolve_asin_jump
from
yswg_utils.common_df
import
get_first_id_from_category_desc_df
class
DwtFlowAsinWeek
(
Templates
):
class
DwtFlowAsinWeek
(
Templates
):
...
@@ -564,11 +565,11 @@ class DwtFlowAsinWeek(Templates):
...
@@ -564,11 +565,11 @@ class DwtFlowAsinWeek(Templates):
"desc_category_first_name"
,
"desc_category_first_name"
,
F
.
lower
(
F
.
trim
(
F
.
split
(
F
.
col
(
"asin_category_desc"
),
"›"
)
.
getItem
(
0
)))
F
.
lower
(
F
.
trim
(
F
.
split
(
F
.
col
(
"asin_category_desc"
),
"›"
)
.
getItem
(
0
)))
)
)
sql_dim
=
f
"""
# 获取一级分类名称与ID的对应关系(与30天流程一致)
select lower(trim(en_name)) as desc_category_first_name, category_first_id as desc_category_first_id
df_bsr_category
=
F
.
broadcast
(
get_first_id_from_category_desc_df
(
self
.
site_name
,
self
.
spark
)
.
select
(
from dim_bsr_category_tree where site_name = '{self.site_name}' and category_parent_id = 0 and leaf_node = 2
F
.
lower
(
F
.
col
(
'category_first_name'
))
.
alias
(
'desc_category_first_name'
),
"""
F
.
col
(
'category_first_id'
)
.
alias
(
'desc_category_first_id'
)
df_bsr_category
=
F
.
broadcast
(
self
.
spark
.
sql
(
sqlQuery
=
sql_dim
))
))
self
.
df_asin_detail
=
self
.
df_asin_detail
.
join
(
df_bsr_category
,
on
=
[
'desc_category_first_name'
],
how
=
'left'
)
self
.
df_asin_detail
=
self
.
df_asin_detail
.
join
(
df_bsr_category
,
on
=
[
'desc_category_first_name'
],
how
=
'left'
)
# 两个分类ID均在过滤列表中才标记为1
# 两个分类ID均在过滤列表中才标记为1
need_categories
=
"('mobile-apps', 'audible', 'books', 'music', 'dmusic', 'digital-text', 'magazines', 'movies-tv', 'software', 'videogames', 'amazon-devices', 'boost', 'us-live-explorations', 'amazon-renewed')"
need_categories
=
"('mobile-apps', 'audible', 'books', 'music', 'dmusic', 'digital-text', 'magazines', 'movies-tv', 'software', 'videogames', 'amazon-devices', 'boost', 'us-live-explorations', 'amazon-renewed')"
...
...
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