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
3ba32d53
Commit
3ba32d53
authored
Sep 04, 2026
by
chenyuanjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "fix"
This reverts commit
c3322548
.
parent
c3322548
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
25 deletions
+15
-25
dwt_amazon_report_pg.py
Pyspark_job/sqoop_export/dwt_amazon_report_pg.py
+15
-25
No files found.
Pyspark_job/sqoop_export/dwt_amazon_report_pg.py
View file @
3ba32d53
...
@@ -23,35 +23,25 @@ if __name__ == '__main__':
...
@@ -23,35 +23,25 @@ if __name__ == '__main__':
engine
=
DBUtil
.
get_db_engine
(
db_type
,
site_name
)
engine
=
DBUtil
.
get_db_engine
(
db_type
,
site_name
)
with
engine
.
connect
()
as
connection
:
with
engine
.
connect
()
as
connection
:
# 不再用 like {master_tb} including all 复制结构:显式建表,新字段直接写进结构里,
# 不需要对线上分布式表 master_tb 做 ALTER TABLE ADD COLUMN(容易触发 Citus 分布式死锁);
# 新字段随着导出完成后的换表流程一起生效。建表时不建索引(导出完成后由 exchange_tb
# 从 master_tb 复制现有索引重建,整表建索引比逐行插入维护索引快很多)
sql
=
f
"""
sql
=
f
"""
DROP TABLE IF EXISTS "public"."{export_tb}";
drop table if exists {export_tb};
CREATE TABLE "public"."{export_tb}" (
create table if not exists {export_tb}
"asin" varchar(20) COLLATE "pg_catalog"."default" NOT NULL,
(
"monthly_sales" text COLLATE "pg_catalog"."default" NOT NULL,
like {master_tb} including ALL
"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