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
fe4ee8a3
Commit
fe4ee8a3
authored
Dec 25, 2025
by
fangxingjun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
cd7680e3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
dim_asin_detail.py
Pyspark_job/dim/dim_asin_detail.py
+5
-5
No files found.
Pyspark_job/dim/dim_asin_detail.py
View file @
fe4ee8a3
...
@@ -106,7 +106,7 @@ class DimAsinDetail(object):
...
@@ -106,7 +106,7 @@ class DimAsinDetail(object):
df_loc
=
df
.
loc
[
df
.
id
==
int
(
cur_id
)
-
21
]
df_loc
=
df
.
loc
[
df
.
id
==
int
(
cur_id
)
-
21
]
week4
=
list
(
df_loc
.
year_week
)[
0
]
week4
=
list
(
df_loc
.
year_week
)[
0
]
complete_date_info_tuple
=
(
week1
,
week2
,
week3
,
week4
)
complete_date_info_tuple
=
(
week1
,
week2
,
week3
,
week4
)
elif
self
.
date_type
in
[
'month'
,
'month_week'
]:
elif
self
.
date_type
in
[
'month'
,
'month_week'
,
'month_aba_me'
]:
df_loc
=
df
.
loc
[(
df
.
year_month
==
f
"{self.date_info}"
)
&
(
df
.
week_day
==
1
)]
df_loc
=
df
.
loc
[(
df
.
year_month
==
f
"{self.date_info}"
)
&
(
df
.
week_day
==
1
)]
complete_date_info_tuple
=
tuple
(
df_loc
.
year_week
)
complete_date_info_tuple
=
tuple
(
df_loc
.
year_week
)
print
(
"self.complete_date_info_tuple:"
,
complete_date_info_tuple
)
print
(
"self.complete_date_info_tuple:"
,
complete_date_info_tuple
)
...
@@ -211,7 +211,7 @@ class DimAsinDetail(object):
...
@@ -211,7 +211,7 @@ class DimAsinDetail(object):
"category_first_name"
,
F
.
lower
(
"category_first_name"
)
"category_first_name"
,
F
.
lower
(
"category_first_name"
)
)
.
repartition
(
100
)
.
persist
(
StorageLevel
.
DISK_ONLY
)
)
.
repartition
(
100
)
.
persist
(
StorageLevel
.
DISK_ONLY
)
self
.
df_asin_category
.
show
(
10
,
truncate
=
False
)
self
.
df_asin_category
.
show
(
10
,
truncate
=
False
)
if
self
.
date_type
in
[
'month'
,
'month_week'
]
and
self
.
date_info
<
'2024-06'
:
if
self
.
date_type
in
[
'month'
,
'month_week'
,
'month_aba_me'
]
and
self
.
date_info
<
'2024-06'
:
sql
=
f
"""
sql
=
f
"""
SELECT asin, parent_asin, color as asin_color, `size` as asin_size, style as asin_style,
SELECT asin, parent_asin, color as asin_color, `size` as asin_size, style as asin_style,
CASE WHEN state = 1 THEN 1 WHEN state = 2 THEN 0 ElSE NULL END as asin_is_sale, updated_time
CASE WHEN state = 1 THEN 1 WHEN state = 2 THEN 0 ElSE NULL END as asin_is_sale, updated_time
...
@@ -301,7 +301,7 @@ class DimAsinDetail(object):
...
@@ -301,7 +301,7 @@ class DimAsinDetail(object):
# 处理asin的配送方式信息
# 处理asin的配送方式信息
def
handle_asin_buy_box_seller_type
(
self
):
def
handle_asin_buy_box_seller_type
(
self
):
if
(
self
.
date_type
in
[
'month'
,
'month_week'
]
and
self
.
date_info
>=
'2024-05'
)
\
if
(
self
.
date_type
in
[
'month'
,
'month_week'
,
'month_aba_me'
]
and
self
.
date_info
>=
'2024-05'
)
\
or
(
self
.
date_type
==
'4_week'
and
self
.
date_info
>=
'2024-21'
):
or
(
self
.
date_type
==
'4_week'
and
self
.
date_info
>=
'2024-21'
):
self
.
df_asin_detail
=
self
.
df_asin_detail
.
withColumn
(
self
.
df_asin_detail
=
self
.
df_asin_detail
.
withColumn
(
'seller_json'
,
'seller_json'
,
...
@@ -443,7 +443,7 @@ class DimAsinDetail(object):
...
@@ -443,7 +443,7 @@ class DimAsinDetail(object):
# 处理asin小图信息
# 处理asin小图信息
def
handle_asin_img_info
(
self
):
def
handle_asin_img_info
(
self
):
if
self
.
date_type
in
[
'month'
,
'month_week'
]
and
self
.
date_info
>=
'2024-06'
:
if
self
.
date_type
in
[
'month'
,
'month_week'
,
'month_aba_me'
]
and
self
.
date_info
>=
'2024-06'
:
img_schema
=
ArrayType
(
ArrayType
(
StringType
()))
img_schema
=
ArrayType
(
ArrayType
(
StringType
()))
df_asin_with_img
=
self
.
df_asin_detail
.
withColumn
(
"img_list"
,
F
.
from_json
(
F
.
col
(
"img_list"
),
img_schema
))
.
filter
(
F
.
size
(
"img_list"
)
>
0
)
.
\
df_asin_with_img
=
self
.
df_asin_detail
.
withColumn
(
"img_list"
,
F
.
from_json
(
F
.
col
(
"img_list"
),
img_schema
))
.
filter
(
F
.
size
(
"img_list"
)
>
0
)
.
\
select
(
"asin"
,
F
.
explode
(
"img_list"
)
.
alias
(
"img_attributes"
))
.
\
select
(
"asin"
,
F
.
explode
(
"img_list"
)
.
alias
(
"img_attributes"
))
.
\
...
@@ -459,7 +459,7 @@ class DimAsinDetail(object):
...
@@ -459,7 +459,7 @@ class DimAsinDetail(object):
# 处理parent_asin下最新变体信息
# 处理parent_asin下最新变体信息
def
handle_latest_variation_info
(
self
):
def
handle_latest_variation_info
(
self
):
if
self
.
date_type
in
[
'month'
,
'month_week'
]
and
self
.
date_info
>=
'2024-06'
:
if
self
.
date_type
in
[
'month'
,
'month_week'
,
'month_aba_me'
]
and
self
.
date_info
>=
'2024-06'
:
max_report_sql
=
f
"""
max_report_sql
=
f
"""
SELECT MAX(date_info) as table_date_info FROM {self.doris_db}.{self.parent_asin_latest_detail_table}
SELECT MAX(date_info) as table_date_info FROM {self.doris_db}.{self.parent_asin_latest_detail_table}
"""
"""
...
...
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