Compare commits

...

2 Commits

Author SHA1 Message Date
root db3fd55f4c add workflow 泰克客户,dev 2024-01-25 21:27:29 +08:00
root ee13a9d0c6 clear workflow 2024-01-25 21:27:29 +08:00
5 changed files with 185 additions and 134 deletions

View File

@ -1,58 +0,0 @@
/*******Main Section**************************************************************************/
\set ON_ERROR_STOP on
\set AUTOCOMMIT on
\timing on
delete from p10_sa.S98_S_china_city
;
insert into p10_sa.S98_S_china_city
( prov_cn
, province
, city_cn
, city
, city_cn2
, city2
, postalcode
, area_code
, area
, etl_tx_dt )
select
prov_cn
, province
, city_cn
, city
, city_cn2
, city2
, postalcode
, area_code
, area
, etl_tx_dt
from p00_tal.S98_S_china_city
;
delete from p12_sfull.S98_S_china_city
;
;
insert into p12_sfull.S98_S_china_city
( prov_cn
, province
, city_cn
, city
, city_cn2
, city2
, postalcode
, area_code
, area
, etl_tx_dt )
select
prov_cn
, province
, city_cn
, city
, city_cn2
, city2
, postalcode
, area_code
, area
, etl_tx_dt
from p10_sa.S98_S_china_city
;
\q

View File

@ -1,21 +0,0 @@
CREATE FOREIGN TABLE if not exists p00_tal.S98_S_china_city (
prov_cn TEXT
, province TEXT
, city_cn TEXT
, city TEXT
, city_cn2 TEXT
, city2 TEXT
, postalcode TEXT
, area_code TEXT
, area TEXT
, etl_tx_dt TIMESTAMP
)
SERVER pgsql_server_S98_S OPTIONS(schema_name 'data_api', table_name 'china_city' );

View File

@ -1,55 +0,0 @@
create table if not exists p10_sa.S98_S_china_city (
prov_cn TEXT
, province TEXT
, city_cn TEXT
, city TEXT
, city_cn2 TEXT
, city2 TEXT
, postalcode TEXT
, area_code TEXT
, area TEXT
, etl_tx_dt TIMESTAMP
) ;
COMMENT ON COLUMN p10_sa.S98_S_china_city.prov_cn IS '省份';
COMMENT ON COLUMN p10_sa.S98_S_china_city.province IS 'province';
COMMENT ON COLUMN p10_sa.S98_S_china_city.city_cn IS '城市';
COMMENT ON COLUMN p10_sa.S98_S_china_city.city IS 'City';
COMMENT ON COLUMN p10_sa.S98_S_china_city.city_cn2 IS '城市2';
COMMENT ON COLUMN p10_sa.S98_S_china_city.city2 IS 'City2';
COMMENT ON COLUMN p10_sa.S98_S_china_city.postalcode IS '邮编/postalcode';
COMMENT ON COLUMN p10_sa.S98_S_china_city.area_code IS '区号/area code';
COMMENT ON COLUMN p10_sa.S98_S_china_city.area IS '区域';
COMMENT ON COLUMN p10_sa.S98_S_china_city.etl_tx_dt IS '';
COMMENT ON TABLE p10_sa.S98_S_china_city IS '';
create table if not exists p12_sfull.S98_S_china_city (
prov_cn TEXT
, province TEXT
, city_cn TEXT
, city TEXT
, city_cn2 TEXT
, city2 TEXT
, postalcode TEXT
, area_code TEXT
, area TEXT
, etl_tx_dt TIMESTAMP
) ;
COMMENT ON COLUMN p12_sfull.S98_S_china_city.prov_cn IS '省份';
COMMENT ON COLUMN p12_sfull.S98_S_china_city.province IS 'province';
COMMENT ON COLUMN p12_sfull.S98_S_china_city.city_cn IS '城市';
COMMENT ON COLUMN p12_sfull.S98_S_china_city.city IS 'City';
COMMENT ON COLUMN p12_sfull.S98_S_china_city.city_cn2 IS '城市2';
COMMENT ON COLUMN p12_sfull.S98_S_china_city.city2 IS 'City2';
COMMENT ON COLUMN p12_sfull.S98_S_china_city.postalcode IS '邮编/postalcode';
COMMENT ON COLUMN p12_sfull.S98_S_china_city.area_code IS '区号/area code';
COMMENT ON COLUMN p12_sfull.S98_S_china_city.area IS '区域';
COMMENT ON COLUMN p12_sfull.S98_S_china_city.etl_tx_dt IS '';
COMMENT ON TABLE p12_sfull.S98_S_china_city IS '';

View File

@ -0,0 +1,26 @@
DROP TABLE IF EXISTS p20_pdm.t00_china_city_info;
CREATE TABLE IF NOT EXISTS p20_pdm.t00_china_city_info (
prov_name varchar(20)
, prov_en varchar(20)
, city_name varchar(20)
, city_en varchar(20)
, city_name2 varchar(20)
, city_en2 varchar(20)
, postalcode varchar(20)
, area_code varchar(20)
, area varchar(20)
,primary key( prov_en,city_en,city_en2 )
);
COMMENT ON COLUMN p20_pdm.t00_china_city_info.prov_name IS '省份';
COMMENT ON COLUMN p20_pdm.t00_china_city_info.prov_en IS 'province';
COMMENT ON COLUMN p20_pdm.t00_china_city_info.city_name IS '城市';
COMMENT ON COLUMN p20_pdm.t00_china_city_info.city_en IS 'City';
COMMENT ON COLUMN p20_pdm.t00_china_city_info.city_name2 IS '城市2';
COMMENT ON COLUMN p20_pdm.t00_china_city_info.city_en2 IS 'City2';
COMMENT ON COLUMN p20_pdm.t00_china_city_info.postalcode IS '邮编/postalcode';
COMMENT ON COLUMN p20_pdm.t00_china_city_info.area_code IS '区号/area code';
COMMENT ON COLUMN p20_pdm.t00_china_city_info.area IS '区域';
COMMENT ON TABLE p20_pdm.t00_china_city_info IS '中国城市信息';

View File

@ -0,0 +1,159 @@
/***************************************************************************************************/
/*script in Sql, generate by SdmCreateScript 2020(by Qihang Feng, QF255001@TERADATA.COM) */
/*VERSION 01.10 revised on 2020-08-25 */
/*Brilliance stems from wisdoms. */
/*************Head Section**************************************************************************/
/*Script Use: Periodically load data to :t00_china_city_info(中国城市信息) */
/*Create Date:2024-01-25 21:26:17 */
/*SDM Developed By: dev */
/*SDM Developed Date: 2024-01-16 */
/*SDM Checked By: dev */
/*SDM Checked Date: 2024-01-25 */
/*Script Developed By: dev */
/*Script Checked By: dev */
/*Source table 1: p10_sa.s98_s_china_city */
/*Job Type: Inbound transform (Tier 1 to Tier 2) */
/*Target Table:t00_china_city_info */
/*ETL Job Name:t00_china_city_info */
/*ETL Frequency:Daily */
/*ETL Policy:F2 */
/********************************************************************************************/
/*******Main Section**************************************************************************/
\set ON_ERROR_STOP on
\set AUTOCOMMIT on
\timing on
/*创建临时表加载当前数据 */
CREATE TEMPORARY TABLE t00_china_city_info_agi_CUR_I
( LIKE :PDMDB.t00_china_city_info)
ON COMMIT PRESERVE ROWS;
/*创建临时表加载不同数据 */
CREATE TEMPORARY TABLE t00_china_city_info_agi_INS
( LIKE :PDMDB.t00_china_city_info)
ON COMMIT PRESERVE ROWS;
/*****************************************************************************************************/
/* GROUP 1:Source Table:s98_s_china_city**************************************************************/
/*****************************************************************************************************/
INSERT INTO t00_china_city_info_agi_CUR_I (
prov_name /*省份*/
,prov_en /*province*/
,city_name /*城市*/
,city_en /*City*/
,city_name2 /*城市2*/
,city_en2 /*City2*/
,postalcode /*邮编/postalcode*/
,area_code /*区号/area code*/
,area /*区域*/
)
SELECT
COALESCE(TRIM(CAST(p0.prov_cn AS varchar(20))),'') /*prov_name*/
,COALESCE(TRIM(CAST(p0.province AS varchar(20))),'') /*prov_en*/
,COALESCE(TRIM(CAST(p0.city_cn AS varchar(20))),'') /*city_name*/
,COALESCE(TRIM(CAST(p0.city AS varchar(20))),'') /*city_en*/
,COALESCE(TRIM(CAST(p0.city_cn2 AS varchar(20))),'') /*city_name2*/
,COALESCE(TRIM(CAST(p0.city2 AS varchar(20))),'') /*city_en2*/
,COALESCE(TRIM(CAST(p0.postalcode AS varchar(20))),'') /*postalcode*/
,COALESCE(TRIM(CAST(p0.area_code AS varchar(20))),'') /*area_code*/
,COALESCE(TRIM(CAST(p0.area AS varchar(20))),'') /*area*/
FROM p10_sa.s98_s_china_city p0
;
/*将不同数据插入到临时表 */
;INSERT INTO t00_china_city_info_agi_INS (
prov_name /*省份*/
,city_name /*城市*/
,city_name2 /*城市2*/
,postalcode /*邮编/postalcode*/
,area_code /*区号/area code*/
,area /*区域*/
,prov_en /*province*/
,city_en /*City*/
,city_en2 /*City2*/
)
SELECT
P1.prov_name /*省份*/
,P1.city_name /*城市*/
,P1.city_name2 /*城市2*/
,P1.postalcode /*邮编/postalcode*/
,P1.area_code /*区号/area code*/
,P1.area /*区域*/
,P1.prov_en /*province*/
,P1.city_en /*City*/
,P1.city_en2 /*City2*/
FROM t00_china_city_info_agi_CUR_I P1
LEFT JOIN :PDMDB.t00_china_city_info P2
ON P1.prov_name = P2.prov_name
AND P1.city_name = P2.city_name
AND P1.city_name2 = P2.city_name2
AND P1.postalcode = P2.postalcode
AND P1.area_code = P2.area_code
AND P1.area = P2.area
AND P1.prov_en = P2.prov_en
AND P1.city_en = P2.city_en
AND P1.city_en2 = P2.city_en2
WHERE P2.prov_name IS NULL
OR P2.city_name IS NULL
OR P2.city_name2 IS NULL
OR P2.postalcode IS NULL
OR P2.area_code IS NULL
OR P2.area IS NULL
OR P2.prov_en IS NULL
OR P2.city_en IS NULL
OR P2.city_en2 IS NULL
;
/*将新增数据插入到目标表 */
;INSERT INTO :PDMDB.t00_china_city_info (
prov_name /*省份*/
,city_name /*城市*/
,city_name2 /*城市2*/
,postalcode /*邮编/postalcode*/
,area_code /*区号/area code*/
,area /*区域*/
,prov_en /*province*/
,city_en /*City*/
,city_en2 /*City2*/
)
SELECT
P1.prov_name /*省份*/
,P1.city_name /*城市*/
,P1.city_name2 /*城市2*/
,P1.postalcode /*邮编/postalcode*/
,P1.area_code /*区号/area code*/
,P1.area /*区域*/
,P1.prov_en /*province*/
,P1.city_en /*City*/
,P1.city_en2 /*City2*/
FROM t00_china_city_info_agi_INS P1
ON CONFLICT ( prov_en,city_en,city_en2)
DO UPDATE SET
prov_en=excluded.prov_en
,city_en=excluded.city_en
,city_en2=excluded.city_en2
,prov_name=excluded.prov_name
,city_name=excluded.city_name
,city_name2=excluded.city_name2
,postalcode=excluded.postalcode
,area_code=excluded.area_code
,area=excluded.area
;
/*****程序结束退出 */
\q