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
10a8426c
Commit
10a8426c
authored
Aug 13, 2025
by
wujicang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update self_asin_redis.py
parent
764c8b08
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
10 deletions
+17
-10
self_asin_redis.py
Pyspark_job/export_other/self_asin_redis.py
+17
-10
No files found.
Pyspark_job/export_other/self_asin_redis.py
View file @
10a8426c
...
@@ -168,11 +168,7 @@ def export():
...
@@ -168,11 +168,7 @@ def export():
img_num,
img_num,
date_format(updated_at, '
%
Y-
%
m-
%
d
%
H:
%
m:
%
S') updated_at,
date_format(updated_at, '
%
Y-
%
m-
%
d
%
H:
%
m:
%
S') updated_at,
date_format(online_time, '
%
Y-
%
m-
%
d
%
H:
%
m:
%
S') online_time,
date_format(online_time, '
%
Y-
%
m-
%
d
%
H:
%
m:
%
S') online_time,
case
returns
when returns = 'Customers usually keep this item' then 1
when returns = 'Frequently returned item' then 2
else 0
end as is_high_return_rate
from {site_name}_self_asin_detail
from {site_name}_self_asin_detail
where updated_at >= '{last_day}'
where updated_at >= '{last_day}'
and updated_at <= '{next_day}'
and updated_at <= '{next_day}'
...
@@ -186,6 +182,14 @@ def export():
...
@@ -186,6 +182,14 @@ def export():
.
where
(
"row_number == 1"
)
\
.
where
(
"row_number == 1"
)
\
.
drop
(
"row_number"
)
.
drop
(
"row_number"
)
asin_df
=
asin_df
.
withColumn
(
"is_high_return_rate"
,
F
.
expr
(
"""
case
when returns = 'Customers usually keep this item' then 1
when returns = 'Frequently returned item' then 2
else 0
end
"""
))
.
drop
(
"returns"
)
# 填充默认值
# 填充默认值
asin_df
=
na_fill
(
asin_df
)
.
cache
()
asin_df
=
na_fill
(
asin_df
)
.
cache
()
if
"redis"
in
export_type
:
if
"redis"
in
export_type
:
...
@@ -305,11 +309,7 @@ def export_all():
...
@@ -305,11 +309,7 @@ def export_all():
img_num,
img_num,
date_format(updated_at, '
%
Y-
%
m-
%
d
%
H:
%
m:
%
S') updated_at,
date_format(updated_at, '
%
Y-
%
m-
%
d
%
H:
%
m:
%
S') updated_at,
date_format(online_time, '
%
Y-
%
m-
%
d
%
H:
%
m:
%
S') online_time,
date_format(online_time, '
%
Y-
%
m-
%
d
%
H:
%
m:
%
S') online_time,
case
returns
when returns = 'Customers usually keep this item' then 1
when returns = 'Frequently returned item' then 2
else 0
end as is_high_return_rate
from (
from (
select max(id) as max_id
select max(id) as max_id
from {site_name}_self_asin_detail
from {site_name}_self_asin_detail
...
@@ -318,6 +318,13 @@ def export_all():
...
@@ -318,6 +318,13 @@ def export_all():
inner join {site_name}_self_asin_detail tmp2 on tmp1.max_id = tmp2.id
inner join {site_name}_self_asin_detail tmp2 on tmp1.max_id = tmp2.id
"""
"""
asin_df
=
SparkUtil
.
read_jdbc
(
spark
,
DbTypes
.
mysql
.
name
,
site_name
,
query
=
query
)
asin_df
=
SparkUtil
.
read_jdbc
(
spark
,
DbTypes
.
mysql
.
name
,
site_name
,
query
=
query
)
asin_df
=
asin_df
.
withColumn
(
"is_high_return_rate"
,
F
.
expr
(
"""
case
when returns = 'Customers usually keep this item' then 1
when returns = 'Frequently returned item' then 2
else 0
end
"""
))
.
drop
(
"returns"
)
# 填充默认值
# 填充默认值
asin_df
=
na_fill
(
asin_df
)
asin_df
=
na_fill
(
asin_df
)
asin_df
.
toJSON
()
.
foreachPartition
(
functools
.
partial
(
save_to_redis_list
,
batch
=
1000
,
redis_key
=
redis_key
,
ttl
=
3600
*
24
*
7
))
asin_df
.
toJSON
()
.
foreachPartition
(
functools
.
partial
(
save_to_redis_list
,
batch
=
1000
,
redis_key
=
redis_key
,
ttl
=
3600
*
24
*
7
))
...
...
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