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
af0bfc59
Commit
af0bfc59
authored
Sep 04, 2026
by
chenyuanjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
流量选品-月销趋势图导出优化
parent
4008bf50
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
15 deletions
+21
-15
dwt_amazon_report_pg.py
Pyspark_job/sqoop_export/dwt_amazon_report_pg.py
+21
-15
No files found.
Pyspark_job/sqoop_export/dwt_amazon_report_pg.py
View file @
af0bfc59
...
@@ -24,24 +24,30 @@ if __name__ == '__main__':
...
@@ -24,24 +24,30 @@ if __name__ == '__main__':
with
engine
.
connect
()
as
connection
:
with
engine
.
connect
()
as
connection
:
sql
=
f
"""
sql
=
f
"""
drop table if exists {export_tb};
DROP TABLE IF EXISTS "public"."{export_tb}";
create table if not exists {export_tb}
CREATE TABLE "public"."{export_tb}" (
(
"asin" varchar(20) COLLATE "pg_catalog"."default" NOT NULL,
like {master_tb} including ALL
"monthly_sales" text COLLATE "pg_catalog"."default" NOT NULL,
"zr_count" text COLLATE "pg_catalog"."default" NOT NULL,
"sp_count" text COLLATE "pg_catalog"."default" NOT NULL,
"total_count" text COLLATE "pg_catalog"."default" NOT NULL,
"date_info_list" text COLLATE "pg_catalog"."default" NOT NULL,
"created_at" timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"weekly_sales" text COLLATE "pg_catalog"."default",
"weekly_views" text COLLATE "pg_catalog"."default",
"monthly_views" text COLLATE "pg_catalog"."default",
"variation_monthly_sales" text COLLATE "pg_catalog"."default" NOT NULL
);
);
COMMENT ON COLUMN "public"."{export_tb}"."asin" IS 'asin';
COMMENT ON COLUMN "public"."{export_tb}"."monthly_sales" IS 'Amazon月销';
COMMENT ON COLUMN "public"."{export_tb}"."zr_count" IS 'zr词数';
COMMENT ON COLUMN "public"."{export_tb}"."sp_count" IS 'sp词数';
COMMENT ON COLUMN "public"."{export_tb}"."total_count" IS '总词数';
COMMENT ON COLUMN "public"."{export_tb}"."date_info_list" IS 'date_info';
COMMENT ON COLUMN "public"."{export_tb}"."variation_monthly_sales" IS '变体销量月度历史(逗号分隔,对齐date_info_list)';
SELECT create_distributed_table('{export_tb}', 'asin');
SELECT create_distributed_table('{export_tb}', 'asin');
DO $$
DECLARE
index_record RECORD;
BEGIN
FOR index_record IN (SELECT indexname FROM pg_indexes WHERE tablename = '{export_tb}')
LOOP
EXECUTE 'DROP INDEX IF EXISTS ' || index_record.indexname;
END LOOP;
END;
$$;
"""
"""
connection
.
execute
(
sql
)
connection
.
execute
(
sql
)
...
...
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