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
9cba6f71
Commit
9cba6f71
authored
Aug 07, 2026
by
chenyuanjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
搜索词中间表兼容landing_asin字段做asin跳转
parent
01428841
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
dwd_st_asin_measure.py
Pyspark_job/dwd/dwd_st_asin_measure.py
+10
-10
No files found.
Pyspark_job/dwd/dwd_st_asin_measure.py
View file @
9cba6f71
...
...
@@ -177,7 +177,7 @@ class DwdStMeasure(Templates):
self
.
df_asin_bs
=
self
.
spark
.
sql
(
sql
)
.
cache
()
self
.
df_asin_bs
.
show
(
10
)
sql
=
f
"select asin, asin_title, asin_price, parent_asin, asin_bought_month,
current_asin, updated_time
"
\
sql
=
f
"select asin, asin_title, asin_price, parent_asin, asin_bought_month,
updated_time, landing_asin
"
\
f
"from dim_asin_detail where site_name='{self.site_name}' and date_type='{self.date_type.replace('_old', '')}' and date_info='{self.date_info}';"
print
(
"sql:"
,
sql
)
self
.
df_asin_detail
=
self
.
spark
.
sql
(
sql
)
.
cache
()
...
...
@@ -361,21 +361,21 @@ class DwdStMeasure(Templates):
self
.
df_st_asin_flow
,
on
=
[
'page_rank'
],
how
=
'left'
)
# === asin跳转处理:将df_st_asin和df_asin_detail的asin统一替换为
current
_asin ===
# 1. 保留原始缓存引用,从中构建跳转映射:原始asin →
current
_asin
# === asin跳转处理:将df_st_asin和df_asin_detail的asin统一替换为
landing
_asin ===
# 1. 保留原始缓存引用,从中构建跳转映射:原始asin →
landing
_asin
df_asin_detail_cached
=
self
.
df_asin_detail
redirect_map
=
df_asin_detail_cached
.
filter
(
F
.
col
(
'
current
_asin'
)
.
isNotNull
())
\
.
select
(
F
.
col
(
'asin'
)
.
alias
(
'redirect_src'
),
F
.
col
(
'
current
_asin'
))
# 2. df_st_asin中的原始asin替换为
current
_asin(无跳转则保留原值)
redirect_map
=
df_asin_detail_cached
.
filter
(
F
.
col
(
'
landing
_asin'
)
.
isNotNull
())
\
.
select
(
F
.
col
(
'asin'
)
.
alias
(
'redirect_src'
),
F
.
col
(
'
landing
_asin'
))
# 2. df_st_asin中的原始asin替换为
landing
_asin(无跳转则保留原值)
self
.
df_st_asin
=
self
.
df_st_asin
\
.
join
(
redirect_map
,
self
.
df_st_asin
.
asin
==
redirect_map
.
redirect_src
,
how
=
'left'
)
\
.
withColumn
(
'asin'
,
F
.
coalesce
(
F
.
col
(
'
current
_asin'
),
F
.
col
(
'asin'
)))
\
.
drop
(
'redirect_src'
,
'
current
_asin'
)
.
withColumn
(
'asin'
,
F
.
coalesce
(
F
.
col
(
'
landing
_asin'
),
F
.
col
(
'asin'
)))
\
.
drop
(
'redirect_src'
,
'
landing
_asin'
)
# 3. df_asin_detail的asin键同步替换,asin重复时按updated_time降序保留最新一条;释放原始缓存
window_redirect
=
Window
.
partitionBy
(
'asin'
)
.
orderBy
(
F
.
col
(
'updated_time'
)
.
desc
())
self
.
df_asin_detail
=
df_asin_detail_cached
\
.
withColumn
(
'asin'
,
F
.
coalesce
(
F
.
col
(
'
current
_asin'
),
F
.
col
(
'asin'
)))
\
.
drop
(
'
current
_asin'
)
\
.
withColumn
(
'asin'
,
F
.
coalesce
(
F
.
col
(
'
landing
_asin'
),
F
.
col
(
'asin'
)))
\
.
drop
(
'
landing
_asin'
)
\
.
withColumn
(
'_rk'
,
F
.
row_number
()
.
over
(
window_redirect
))
\
.
filter
(
F
.
col
(
'_rk'
)
==
1
)
\
.
drop
(
'_rk'
,
'updated_time'
)
\
...
...
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