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
c9083973
Commit
c9083973
authored
Sep 03, 2026
by
chenyuanjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
流量选品-变体销量趋势图
parent
1165e91b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
22 deletions
+25
-22
dwt_amazon_report.py
Pyspark_job/dwt/dwt_amazon_report.py
+25
-22
No files found.
Pyspark_job/dwt/dwt_amazon_report.py
View file @
c9083973
...
@@ -33,16 +33,17 @@ class DwtAmazonReport(Templates):
...
@@ -33,16 +33,17 @@ class DwtAmazonReport(Templates):
def
read_data
(
self
):
def
read_data
(
self
):
# 读取流量选品本月月销数据
# 读取流量选品本月月销数据
sql1
=
f
"""
sql1
=
f
"""
select
select
asin,
asin,
asin_bought_month as new_monthly_sales,
asin_bought_month as new_monthly_sales,
asin_zr_counts as new_zr_count,
asin_zr_counts as new_zr_count,
asin_sp_counts as new_sp_count,
asin_sp_counts as new_sp_count,
asin_st_counts as new_total_count,
asin_st_counts as new_total_count,
date_info as new_date_info_list
date_info as new_date_info_list,
from dwt_flow_asin
variation_bought_month as new_variation_monthly_sales
where site_name = '{self.site_name}'
from dwt_flow_asin
and date_type = '{self.date_type}'
where site_name = '{self.site_name}'
and date_type = '{self.date_type}'
and date_info = '{self.date_info}';
and date_info = '{self.date_info}';
"""
"""
self
.
df_asin_detail_new
=
self
.
spark
.
sql
(
sqlQuery
=
sql1
)
.
repartition
(
15
,
'asin'
)
.
fillna
(
'-1'
)
.
cache
()
self
.
df_asin_detail_new
=
self
.
spark
.
sql
(
sqlQuery
=
sql1
)
.
repartition
(
15
,
'asin'
)
.
fillna
(
'-1'
)
.
cache
()
...
@@ -50,24 +51,26 @@ class DwtAmazonReport(Templates):
...
@@ -50,24 +51,26 @@ class DwtAmazonReport(Templates):
# 读历史数据
# 读历史数据
sql2
=
f
"""
sql2
=
f
"""
select
select
asin,
asin,
monthly_sales as old_monthly_sales,
monthly_sales as old_monthly_sales,
zr_count as old_zr_count,
zr_count as old_zr_count,
sp_count as old_sp_count,
sp_count as old_sp_count,
total_count as old_total_count,
total_count as old_total_count,
date_info_list as old_date_info_list
date_info_list as old_date_info_list,
from dwt_amazon_report
variation_monthly_sales as old_variation_monthly_sales
where site_name = '{self.site_name}'
from dwt_amazon_report
and date_type = '{self.date_type}'
where site_name = '{self.site_name}'
and date_type = '{self.date_type}'
and date_info = '{self.date_info_pre}';
and date_info = '{self.date_info_pre}';
"""
"""
self
.
df_asin_detail_old
=
self
.
spark
.
sql
(
sqlQuery
=
sql2
)
.
repartition
(
15
,
'asin'
)
.
cache
()
self
.
df_asin_detail_old
=
self
.
spark
.
sql
(
sqlQuery
=
sql2
)
.
repartition
(
15
,
'asin'
)
.
cache
()
self
.
df_asin_detail_old
.
show
(
10
,
truncate
=
True
)
self
.
df_asin_detail_old
.
show
(
10
,
truncate
=
True
)
def
handle_data
(
self
):
def
handle_data
(
self
):
# 关联后的列名
# 关联后的列名(新增字段放末尾)
join_columns
=
[
'monthly_sales'
,
'zr_count'
,
'sp_count'
,
'total_count'
,
'date_info_list'
]
join_columns
=
[
'monthly_sales'
,
'zr_count'
,
'sp_count'
,
'total_count'
,
'date_info_list'
,
'variation_monthly_sales'
]
# 获取历史df对象中,date_info的数量,用来确定关联不到的历史asin填充多少个 -1
# 获取历史df对象中,date_info的数量,用来确定关联不到的历史asin填充多少个 -1
old_date_info_first
=
self
.
df_asin_detail_old
.
select
(
'old_date_info_list'
)
.
distinct
()
.
first
()
old_date_info_first
=
self
.
df_asin_detail_old
.
select
(
'old_date_info_list'
)
.
distinct
()
.
first
()
if
old_date_info_first
is
None
:
if
old_date_info_first
is
None
:
...
...
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