Compare commits
No commits in common. "1ff39d95e0f312094e4f90676b16b47e3296fb8d" and "7136dbabe6fd20769148fe19f4822ba98289e54f" have entirely different histories.
1ff39d95e0
...
7136dbabe6
|
@ -0,0 +1,46 @@
|
|||
|
||||
DROP TABLE IF EXISTS p20_pdm.t01_scrm_leads;
|
||||
CREATE TABLE IF NOT EXISTS p20_pdm.t01_scrm_leads (
|
||||
customer_id varchar(30)
|
||||
, date timestamp(0)
|
||||
, target_name varchar(30)
|
||||
, c_name varchar(30)
|
||||
, c_type varchar(30)
|
||||
, content_name varchar(30)
|
||||
, source varchar(50)
|
||||
, tag varchar(30)
|
||||
, c_keyword varchar(30)
|
||||
, attr2 varchar(30)
|
||||
, label varchar(30)
|
||||
, group_label varchar(30)
|
||||
, Etl_Batch_No varchar(50)
|
||||
, Etl_First_Dt timestamp(0)
|
||||
, Etl_Job varchar(50)
|
||||
, Etl_Proc_Dt timestamp(0)
|
||||
, Etl_Tx_Dt timestamp(0)
|
||||
, Src_Sysname varchar(50)
|
||||
, Src_Table varchar(50)
|
||||
,primary key( customer_id,date )
|
||||
);
|
||||
|
||||
COMMENT ON COLUMN p20_pdm.t01_scrm_leads.customer_id IS 'customerId';
|
||||
COMMENT ON COLUMN p20_pdm.t01_scrm_leads.date IS 'date';
|
||||
COMMENT ON COLUMN p20_pdm.t01_scrm_leads.target_name IS 'targetName';
|
||||
COMMENT ON COLUMN p20_pdm.t01_scrm_leads.c_name IS 'c_name';
|
||||
COMMENT ON COLUMN p20_pdm.t01_scrm_leads.c_type IS 'c_type';
|
||||
COMMENT ON COLUMN p20_pdm.t01_scrm_leads.content_name IS 'contentName';
|
||||
COMMENT ON COLUMN p20_pdm.t01_scrm_leads.source IS 'source';
|
||||
COMMENT ON COLUMN p20_pdm.t01_scrm_leads.tag IS 'tag';
|
||||
COMMENT ON COLUMN p20_pdm.t01_scrm_leads.c_keyword IS 'c_keyword';
|
||||
COMMENT ON COLUMN p20_pdm.t01_scrm_leads.attr2 IS 'attr2';
|
||||
COMMENT ON COLUMN p20_pdm.t01_scrm_leads.label IS 'label';
|
||||
COMMENT ON COLUMN p20_pdm.t01_scrm_leads.group_label IS 'groupLabel';
|
||||
COMMENT ON COLUMN p20_pdm.t01_scrm_leads.Etl_Batch_No IS '作业批次号';
|
||||
COMMENT ON COLUMN p20_pdm.t01_scrm_leads.Etl_First_Dt IS '最初入库时间';
|
||||
COMMENT ON COLUMN p20_pdm.t01_scrm_leads.Etl_Job IS '作业名称';
|
||||
COMMENT ON COLUMN p20_pdm.t01_scrm_leads.Etl_Proc_Dt IS '本次入库时间';
|
||||
COMMENT ON COLUMN p20_pdm.t01_scrm_leads.Etl_Tx_Dt IS '作业运行时间';
|
||||
COMMENT ON COLUMN p20_pdm.t01_scrm_leads.Src_Sysname IS '来源系统';
|
||||
COMMENT ON COLUMN p20_pdm.t01_scrm_leads.Src_Table IS '来源表';
|
||||
|
||||
COMMENT ON TABLE p20_pdm.t01_scrm_leads IS 'SCRM线索';
|
|
@ -0,0 +1,235 @@
|
|||
/***************************************************************************************************/
|
||||
/*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 :t01_scrm_leads(SCRM线索) */
|
||||
/*Create Date:2024-01-18 15:33:38 */
|
||||
/*SDM Developed By: dev */
|
||||
/*SDM Developed Date: 2024-01-12 */
|
||||
/*SDM Checked By: dev */
|
||||
/*SDM Checked Date: 2024-01-18 */
|
||||
/*Script Developed By: dev */
|
||||
/*Script Checked By: dev */
|
||||
/*Source table 1: p10_sa.s98_s_scrm_leads_af0912 */
|
||||
/*Job Type: Inbound transform (Tier 1 to Tier 2) */
|
||||
/*Target Table:t01_scrm_leads */
|
||||
/*ETL Job Name:t01_scrm_leads */
|
||||
/*ETL Frequency:Daily */
|
||||
/*ETL Policy:F2 */
|
||||
/********************************************************************************************/
|
||||
/*******Main Section**************************************************************************/
|
||||
\set ON_ERROR_STOP on
|
||||
\set AUTOCOMMIT on
|
||||
\timing on
|
||||
|
||||
|
||||
|
||||
/*创建临时表加载当前数据 */
|
||||
CREATE TEMPORARY TABLE t01_scrm_leads_agi_CUR_I
|
||||
( LIKE :PDMDB.t01_scrm_leads)
|
||||
ON COMMIT PRESERVE ROWS;
|
||||
|
||||
|
||||
|
||||
/*创建临时表加载不同数据 */
|
||||
CREATE TEMPORARY TABLE t01_scrm_leads_agi_INS
|
||||
( LIKE :PDMDB.t01_scrm_leads)
|
||||
ON COMMIT PRESERVE ROWS;
|
||||
|
||||
|
||||
/*****************************************************************************************************/
|
||||
/* GROUP 1:Source Table:s98_s_scrm_leads_af0912*******************************************************/
|
||||
/*****************************************************************************************************/
|
||||
INSERT INTO t01_scrm_leads_agi_CUR_I (
|
||||
customer_id /*customerId*/
|
||||
,date /*date*/
|
||||
,target_name /*targetName*/
|
||||
,c_name /*c_name*/
|
||||
,c_type /*c_type*/
|
||||
,content_name /*contentName*/
|
||||
,source /*source*/
|
||||
,tag /*tag*/
|
||||
,c_keyword /*c_keyword*/
|
||||
,attr2 /*attr2*/
|
||||
,label /*label*/
|
||||
,group_label /*groupLabel*/
|
||||
,Etl_Batch_No /*作业批次号*/
|
||||
,Etl_First_Dt /*最初入库时间*/
|
||||
,Etl_Job /*作业名称*/
|
||||
,Etl_Proc_Dt /*本次入库时间*/
|
||||
,Etl_Tx_Dt /*作业运行时间*/
|
||||
,Src_Sysname /*来源系统*/
|
||||
,Src_Table /*来源表*/
|
||||
)
|
||||
SELECT
|
||||
COALESCE(TRIM(CAST(p0.customer_id AS varchar(30))),'') /*customer_id*/
|
||||
,COALESCE(TO_TIMESTAMP(CAST(p0.date AS VARCHAR(19)),'YYYY-MM-DD HH24:mi:ss'),TO_TIMESTAMP(:NULLDATE,'YYYYMMDD')) /*date*/
|
||||
,COALESCE(TRIM(CAST(p0.target_name AS varchar(30))),'') /*target_name*/
|
||||
,COALESCE(TRIM(CAST(p0.c_name AS varchar(30))),'') /*c_name*/
|
||||
,COALESCE(TRIM(CAST(p0.c_type AS varchar(30))),'') /*c_type*/
|
||||
,COALESCE(TRIM(CAST(p0.content_name AS varchar(30))),'') /*content_name*/
|
||||
,COALESCE(TRIM(CAST(p0.source AS varchar(50))),'') /*source*/
|
||||
,COALESCE(TRIM(CAST(p0.tag AS varchar(30))),'') /*tag*/
|
||||
,COALESCE(TRIM(CAST(p0.c_keyword AS varchar(30))),'') /*c_keyword*/
|
||||
,COALESCE(TRIM(CAST(p0.attr2 AS varchar(30))),'') /*attr2*/
|
||||
,COALESCE(TRIM(CAST(p0.label AS varchar(30))),'') /*label*/
|
||||
,COALESCE(TRIM(CAST(p0.group_label AS varchar(30))),'') /*group_label*/
|
||||
,0 /*Etl_Batch_No*/
|
||||
,TO_DATE(:TXDATE,'YYYYMMDD') /*Etl_First_Dt*/
|
||||
,:ETLJOB /*Etl_Job*/
|
||||
,current_timestamp(0) /*Etl_Proc_Dt*/
|
||||
,TO_DATE(:TXDATE,'YYYYMMDD') /*Etl_Tx_Dt*/
|
||||
,Substr('s98_s_scrm_leads_af0912',1,3) /*Src_Sysname*/
|
||||
,'s98_s_scrm_leads_af0912' /*Src_Table*/
|
||||
|
||||
FROM p10_sa.s98_s_scrm_leads_af0912 p0
|
||||
;
|
||||
|
||||
|
||||
|
||||
/*将不同数据插入到临时表 */
|
||||
;INSERT INTO t01_scrm_leads_agi_INS (
|
||||
target_name /*targetName*/
|
||||
,c_name /*c_name*/
|
||||
,c_type /*c_type*/
|
||||
,content_name /*contentName*/
|
||||
,source /*source*/
|
||||
,tag /*tag*/
|
||||
,c_keyword /*c_keyword*/
|
||||
,attr2 /*attr2*/
|
||||
,label /*label*/
|
||||
,group_label /*groupLabel*/
|
||||
,customer_id /*customerId*/
|
||||
,date /*date*/
|
||||
,Etl_Batch_No /*作业批次号*/
|
||||
,Etl_First_Dt /*最初入库时间*/
|
||||
,Etl_Job /*作业名称*/
|
||||
,Etl_Proc_Dt /*本次入库时间*/
|
||||
,Etl_Tx_Dt /*作业运行时间*/
|
||||
,Src_Sysname /*来源系统*/
|
||||
,Src_Table /*来源表*/
|
||||
|
||||
)
|
||||
SELECT
|
||||
P1.target_name /*targetName*/
|
||||
,P1.c_name /*c_name*/
|
||||
,P1.c_type /*c_type*/
|
||||
,P1.content_name /*contentName*/
|
||||
,P1.source /*source*/
|
||||
,P1.tag /*tag*/
|
||||
,P1.c_keyword /*c_keyword*/
|
||||
,P1.attr2 /*attr2*/
|
||||
,P1.label /*label*/
|
||||
,P1.group_label /*groupLabel*/
|
||||
,P1.customer_id /*customerId*/
|
||||
,P1.date /*date*/
|
||||
,P1.Etl_Batch_No /*作业批次号*/
|
||||
,P1.Etl_First_Dt /*最初入库时间*/
|
||||
,P1.Etl_Job /*作业名称*/
|
||||
,P1.Etl_Proc_Dt /*本次入库时间*/
|
||||
,P1.Etl_Tx_Dt /*作业运行时间*/
|
||||
,P1.Src_Sysname /*来源系统*/
|
||||
,P1.Src_Table /*来源表*/
|
||||
|
||||
FROM t01_scrm_leads_agi_CUR_I P1
|
||||
LEFT JOIN :PDMDB.t01_scrm_leads P2
|
||||
ON P1.target_name = P2.target_name
|
||||
AND P1.c_name = P2.c_name
|
||||
AND P1.c_type = P2.c_type
|
||||
AND P1.content_name = P2.content_name
|
||||
AND P1.source = P2.source
|
||||
AND P1.tag = P2.tag
|
||||
AND P1.c_keyword = P2.c_keyword
|
||||
AND P1.attr2 = P2.attr2
|
||||
AND P1.label = P2.label
|
||||
AND P1.group_label = P2.group_label
|
||||
AND P1.customer_id = P2.customer_id
|
||||
AND P1.date = P2.date
|
||||
|
||||
WHERE P2.target_name IS NULL
|
||||
OR P2.c_name IS NULL
|
||||
OR P2.c_type IS NULL
|
||||
OR P2.content_name IS NULL
|
||||
OR P2.source IS NULL
|
||||
OR P2.tag IS NULL
|
||||
OR P2.c_keyword IS NULL
|
||||
OR P2.attr2 IS NULL
|
||||
OR P2.label IS NULL
|
||||
OR P2.group_label IS NULL
|
||||
OR P2.customer_id IS NULL
|
||||
OR P2.date IS NULL
|
||||
|
||||
;
|
||||
/*将新增数据插入到目标表 */
|
||||
;INSERT INTO :PDMDB.t01_scrm_leads (
|
||||
target_name /*targetName*/
|
||||
,c_name /*c_name*/
|
||||
,c_type /*c_type*/
|
||||
,content_name /*contentName*/
|
||||
,source /*source*/
|
||||
,tag /*tag*/
|
||||
,c_keyword /*c_keyword*/
|
||||
,attr2 /*attr2*/
|
||||
,label /*label*/
|
||||
,group_label /*groupLabel*/
|
||||
,customer_id /*customerId*/
|
||||
,date /*date*/
|
||||
,Etl_Batch_No /*作业批次号*/
|
||||
,Etl_First_Dt /*最初入库时间*/
|
||||
,Etl_Job /*作业名称*/
|
||||
,Etl_Proc_Dt /*本次入库时间*/
|
||||
,Etl_Tx_Dt /*作业运行时间*/
|
||||
,Src_Sysname /*来源系统*/
|
||||
,Src_Table /*来源表*/
|
||||
|
||||
)
|
||||
SELECT
|
||||
P1.target_name /*targetName*/
|
||||
,P1.c_name /*c_name*/
|
||||
,P1.c_type /*c_type*/
|
||||
,P1.content_name /*contentName*/
|
||||
,P1.source /*source*/
|
||||
,P1.tag /*tag*/
|
||||
,P1.c_keyword /*c_keyword*/
|
||||
,P1.attr2 /*attr2*/
|
||||
,P1.label /*label*/
|
||||
,P1.group_label /*groupLabel*/
|
||||
,P1.customer_id /*customerId*/
|
||||
,P1.date /*date*/
|
||||
,P1.Etl_Batch_No /*作业批次号*/
|
||||
,P1.Etl_First_Dt /*最初入库时间*/
|
||||
,P1.Etl_Job /*作业名称*/
|
||||
,P1.Etl_Proc_Dt /*本次入库时间*/
|
||||
,P1.Etl_Tx_Dt /*作业运行时间*/
|
||||
,P1.Src_Sysname /*来源系统*/
|
||||
,P1.Src_Table /*来源表*/
|
||||
|
||||
FROM t01_scrm_leads_agi_INS P1
|
||||
ON CONFLICT ( customer_id,date)
|
||||
DO UPDATE SET
|
||||
customer_id=excluded.customer_id
|
||||
,date=excluded.date
|
||||
,target_name=excluded.target_name
|
||||
,c_name=excluded.c_name
|
||||
,c_type=excluded.c_type
|
||||
,content_name=excluded.content_name
|
||||
,source=excluded.source
|
||||
,tag=excluded.tag
|
||||
,c_keyword=excluded.c_keyword
|
||||
,attr2=excluded.attr2
|
||||
,label=excluded.label
|
||||
,group_label=excluded.group_label
|
||||
,Etl_Batch_No=excluded.Etl_Batch_No
|
||||
,Etl_First_Dt=excluded.Etl_First_Dt
|
||||
,Etl_Job=excluded.Etl_Job
|
||||
,Etl_Proc_Dt=excluded.Etl_Proc_Dt
|
||||
,Etl_Tx_Dt=excluded.Etl_Tx_Dt
|
||||
,Src_Sysname=excluded.Src_Sysname
|
||||
,Src_Table=excluded.Src_Table
|
||||
|
||||
|
||||
;
|
||||
/*****程序结束退出 */
|
||||
\q
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
|
||||
DROP TABLE IF EXISTS p20_pdm.t01_scrm_leads_his;
|
||||
CREATE TABLE IF NOT EXISTS p20_pdm.t01_scrm_leads_his (
|
||||
cue_id varchar(30)
|
||||
, activate_time timestamp(0)
|
||||
, activate_name varchar(30)
|
||||
, event_name varchar(30)
|
||||
, Etl_Batch_No varchar(50)
|
||||
, Etl_First_Dt timestamp(0)
|
||||
, Etl_Job varchar(50)
|
||||
, Etl_Proc_Dt timestamp(0)
|
||||
, Etl_Tx_Dt timestamp(0)
|
||||
, Src_Sysname varchar(50)
|
||||
, Src_Table varchar(50)
|
||||
,primary key( cue_id,activate_time )
|
||||
);
|
||||
|
||||
COMMENT ON COLUMN p20_pdm.t01_scrm_leads_his.cue_id IS '线索ID';
|
||||
COMMENT ON COLUMN p20_pdm.t01_scrm_leads_his.activate_time IS '活动时间';
|
||||
COMMENT ON COLUMN p20_pdm.t01_scrm_leads_his.activate_name IS '活动名称';
|
||||
COMMENT ON COLUMN p20_pdm.t01_scrm_leads_his.event_name IS '事件名称';
|
||||
COMMENT ON COLUMN p20_pdm.t01_scrm_leads_his.Etl_Batch_No IS '作业批次号';
|
||||
COMMENT ON COLUMN p20_pdm.t01_scrm_leads_his.Etl_First_Dt IS '最初入库时间';
|
||||
COMMENT ON COLUMN p20_pdm.t01_scrm_leads_his.Etl_Job IS '作业名称';
|
||||
COMMENT ON COLUMN p20_pdm.t01_scrm_leads_his.Etl_Proc_Dt IS '本次入库时间';
|
||||
COMMENT ON COLUMN p20_pdm.t01_scrm_leads_his.Etl_Tx_Dt IS '作业运行时间';
|
||||
COMMENT ON COLUMN p20_pdm.t01_scrm_leads_his.Src_Sysname IS '来源系统';
|
||||
COMMENT ON COLUMN p20_pdm.t01_scrm_leads_his.Src_Table IS '来源表';
|
||||
|
||||
COMMENT ON TABLE p20_pdm.t01_scrm_leads_his IS 'SCRM线索历史';
|
|
@ -0,0 +1,163 @@
|
|||
/***************************************************************************************************/
|
||||
/*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 :t01_scrm_leads_his(SCRM线索历史) */
|
||||
/*Create Date:2024-01-18 15:31:15 */
|
||||
/*SDM Developed By: dev */
|
||||
/*SDM Developed Date: 2024-01-12 */
|
||||
/*SDM Checked By: dev */
|
||||
/*SDM Checked Date: 2024-01-18 */
|
||||
/*Script Developed By: dev */
|
||||
/*Script Checked By: dev */
|
||||
/*Source table 1: p10_sa.s98_s_scrm_leads_bf0912 */
|
||||
/*Job Type: Inbound transform (Tier 1 to Tier 2) */
|
||||
/*Target Table:t01_scrm_leads_his */
|
||||
/*ETL Job Name:t01_scrm_leads_his */
|
||||
/*ETL Frequency:Daily */
|
||||
/*ETL Policy:F2 */
|
||||
/********************************************************************************************/
|
||||
/*******Main Section**************************************************************************/
|
||||
\set ON_ERROR_STOP on
|
||||
\set AUTOCOMMIT on
|
||||
\timing on
|
||||
|
||||
|
||||
|
||||
/*创建临时表加载当前数据 */
|
||||
CREATE TEMPORARY TABLE t01_scrm_leads_his_agi_CUR_I
|
||||
( LIKE :PDMDB.t01_scrm_leads_his)
|
||||
ON COMMIT PRESERVE ROWS;
|
||||
|
||||
|
||||
|
||||
/*创建临时表加载不同数据 */
|
||||
CREATE TEMPORARY TABLE t01_scrm_leads_his_agi_INS
|
||||
( LIKE :PDMDB.t01_scrm_leads_his)
|
||||
ON COMMIT PRESERVE ROWS;
|
||||
|
||||
|
||||
/*****************************************************************************************************/
|
||||
/* GROUP 1:Source Table:s98_s_scrm_leads_bf0912*******************************************************/
|
||||
/*****************************************************************************************************/
|
||||
INSERT INTO t01_scrm_leads_his_agi_CUR_I (
|
||||
cue_id /*线索ID*/
|
||||
,activate_time /*活动时间*/
|
||||
,activate_name /*活动名称*/
|
||||
,event_name /*事件名称*/
|
||||
,Etl_Batch_No /*作业批次号*/
|
||||
,Etl_First_Dt /*最初入库时间*/
|
||||
,Etl_Job /*作业名称*/
|
||||
,Etl_Proc_Dt /*本次入库时间*/
|
||||
,Etl_Tx_Dt /*作业运行时间*/
|
||||
,Src_Sysname /*来源系统*/
|
||||
,Src_Table /*来源表*/
|
||||
)
|
||||
SELECT
|
||||
COALESCE(TRIM(CAST(p0.cue_id AS varchar(30))),'') /*cue_id*/
|
||||
,COALESCE(TO_TIMESTAMP(CAST(p0.activate_time AS VARCHAR(19)),'YYYY-MM-DD HH24:mi:ss'),TO_TIMESTAMP(:NULLDATE,'YYYYMMDD')) /*activate_time*/
|
||||
,COALESCE(TRIM(CAST(p0.activate_name AS varchar(30))),'') /*activate_name*/
|
||||
,COALESCE(TRIM(CAST(p0.event_name AS varchar(30))),'') /*event_name*/
|
||||
,0 /*Etl_Batch_No*/
|
||||
,TO_DATE(:TXDATE,'YYYYMMDD') /*Etl_First_Dt*/
|
||||
,:ETLJOB /*Etl_Job*/
|
||||
,current_timestamp(0) /*Etl_Proc_Dt*/
|
||||
,TO_DATE(:TXDATE,'YYYYMMDD') /*Etl_Tx_Dt*/
|
||||
,Substr('s98_s_scrm_leads_bf0912',1,3) /*Src_Sysname*/
|
||||
,'s98_s_scrm_leads_bf0912' /*Src_Table*/
|
||||
|
||||
FROM p10_sa.s98_s_scrm_leads_bf0912 p0
|
||||
;
|
||||
|
||||
|
||||
|
||||
/*将不同数据插入到临时表 */
|
||||
;INSERT INTO t01_scrm_leads_his_agi_INS (
|
||||
activate_name /*活动名称*/
|
||||
,event_name /*事件名称*/
|
||||
,cue_id /*线索ID*/
|
||||
,activate_time /*活动时间*/
|
||||
,Etl_Batch_No /*作业批次号*/
|
||||
,Etl_First_Dt /*最初入库时间*/
|
||||
,Etl_Job /*作业名称*/
|
||||
,Etl_Proc_Dt /*本次入库时间*/
|
||||
,Etl_Tx_Dt /*作业运行时间*/
|
||||
,Src_Sysname /*来源系统*/
|
||||
,Src_Table /*来源表*/
|
||||
|
||||
)
|
||||
SELECT
|
||||
P1.activate_name /*活动名称*/
|
||||
,P1.event_name /*事件名称*/
|
||||
,P1.cue_id /*线索ID*/
|
||||
,P1.activate_time /*活动时间*/
|
||||
,P1.Etl_Batch_No /*作业批次号*/
|
||||
,P1.Etl_First_Dt /*最初入库时间*/
|
||||
,P1.Etl_Job /*作业名称*/
|
||||
,P1.Etl_Proc_Dt /*本次入库时间*/
|
||||
,P1.Etl_Tx_Dt /*作业运行时间*/
|
||||
,P1.Src_Sysname /*来源系统*/
|
||||
,P1.Src_Table /*来源表*/
|
||||
|
||||
FROM t01_scrm_leads_his_agi_CUR_I P1
|
||||
LEFT JOIN :PDMDB.t01_scrm_leads_his P2
|
||||
ON P1.activate_name = P2.activate_name
|
||||
AND P1.event_name = P2.event_name
|
||||
AND P1.cue_id = P2.cue_id
|
||||
AND P1.activate_time = P2.activate_time
|
||||
|
||||
WHERE P2.activate_name IS NULL
|
||||
OR P2.event_name IS NULL
|
||||
OR P2.cue_id IS NULL
|
||||
OR P2.activate_time IS NULL
|
||||
|
||||
;
|
||||
/*将新增数据插入到目标表 */
|
||||
;INSERT INTO :PDMDB.t01_scrm_leads_his (
|
||||
activate_name /*活动名称*/
|
||||
,event_name /*事件名称*/
|
||||
,cue_id /*线索ID*/
|
||||
,activate_time /*活动时间*/
|
||||
,Etl_Batch_No /*作业批次号*/
|
||||
,Etl_First_Dt /*最初入库时间*/
|
||||
,Etl_Job /*作业名称*/
|
||||
,Etl_Proc_Dt /*本次入库时间*/
|
||||
,Etl_Tx_Dt /*作业运行时间*/
|
||||
,Src_Sysname /*来源系统*/
|
||||
,Src_Table /*来源表*/
|
||||
|
||||
)
|
||||
SELECT
|
||||
P1.activate_name /*活动名称*/
|
||||
,P1.event_name /*事件名称*/
|
||||
,P1.cue_id /*线索ID*/
|
||||
,P1.activate_time /*活动时间*/
|
||||
,P1.Etl_Batch_No /*作业批次号*/
|
||||
,P1.Etl_First_Dt /*最初入库时间*/
|
||||
,P1.Etl_Job /*作业名称*/
|
||||
,P1.Etl_Proc_Dt /*本次入库时间*/
|
||||
,P1.Etl_Tx_Dt /*作业运行时间*/
|
||||
,P1.Src_Sysname /*来源系统*/
|
||||
,P1.Src_Table /*来源表*/
|
||||
|
||||
FROM t01_scrm_leads_his_agi_INS P1
|
||||
ON CONFLICT ( cue_id,activate_time)
|
||||
DO UPDATE SET
|
||||
cue_id=excluded.cue_id
|
||||
,activate_time=excluded.activate_time
|
||||
,activate_name=excluded.activate_name
|
||||
,event_name=excluded.event_name
|
||||
,Etl_Batch_No=excluded.Etl_Batch_No
|
||||
,Etl_First_Dt=excluded.Etl_First_Dt
|
||||
,Etl_Job=excluded.Etl_Job
|
||||
,Etl_Proc_Dt=excluded.Etl_Proc_Dt
|
||||
,Etl_Tx_Dt=excluded.Etl_Tx_Dt
|
||||
,Src_Sysname=excluded.Src_Sysname
|
||||
,Src_Table=excluded.Src_Table
|
||||
|
||||
|
||||
;
|
||||
/*****程序结束退出 */
|
||||
\q
|
||||
|
|
@ -1,351 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# -*- encoding=utf-8 -*-
|
||||
from airflow import DAG
|
||||
from datetime import datetime, timedelta
|
||||
from airflow.contrib.hooks.ssh_hook import SSHHook
|
||||
from airflow.contrib.operators.ssh_operator import SSHOperator
|
||||
from airflow.sensors.external_task_sensor import ExternalTaskSensor
|
||||
import json
|
||||
|
||||
from airflow.operators.email_operator import EmailOperator
|
||||
from airflow.utils.trigger_rule import TriggerRule
|
||||
|
||||
|
||||
sshHook = SSHHook(ssh_conn_id ='ssh_air')
|
||||
default_args = {
|
||||
'owner': 'info@idgvalue.com',
|
||||
'email': [''],
|
||||
'email_on_failure': True,
|
||||
'email_on_retry':True,
|
||||
'start_date': datetime(2022, 9, 12),
|
||||
'depends_on_past': False,
|
||||
'retries': 6,
|
||||
'retry_delay': timedelta(minutes=10),
|
||||
}
|
||||
|
||||
dag = DAG('wf_dag_tk_cust', default_args=default_args,
|
||||
schedule_interval="0 0 * * *",
|
||||
catchup=False,
|
||||
dagrun_timeout=timedelta(minutes=160),
|
||||
max_active_runs=3)
|
||||
|
||||
task_failed = EmailOperator (
|
||||
dag=dag,
|
||||
trigger_rule=TriggerRule.ONE_FAILED,
|
||||
task_id="task_failed",
|
||||
to=["info@idgvalue.com"],
|
||||
cc=[""],
|
||||
subject="tk_cust_failed",
|
||||
html_content='<h3>您好,tk_cust作业失败,请及时处理" </h3>')
|
||||
|
||||
file_Tk01 = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='file_Tk01',
|
||||
command='python /data/airflow/bin/FILELOD.py {{ params.my_param }} {{ ds_nodash }} >>/data/airflow/logs/file_load/file_load_{{ds_nodash}}.log 2>&1 ',
|
||||
params={'my_param':"Tk01"},
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
|
||||
|
||||
file_Update_af0912 = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='file_Update_af0912',
|
||||
command='python /data/airflow/bin/FILELOD.py {{ params.my_param }} {{ ds_nodash }} >>/data/airflow/logs/file_load/file_load_{{ds_nodash}}.log 2>&1 ',
|
||||
params={'my_param':"Update_af0912"},
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
|
||||
|
||||
file_Merge_af0912 = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='file_Merge_af0912',
|
||||
command='python /data/airflow/bin/FILELOD.py {{ params.my_param }} {{ ds_nodash }} >>/data/airflow/logs/file_load/file_load_{{ds_nodash}}.log 2>&1 ',
|
||||
params={'my_param':"Merge_af0912"},
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
|
||||
|
||||
file_SCRM_Contact_af0912 = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='file_SCRM_Contact_af0912',
|
||||
command='python /data/airflow/bin/FILELOD.py {{ params.my_param }} {{ ds_nodash }} >>/data/airflow/logs/file_load/file_load_{{ds_nodash}}.log 2>&1 ',
|
||||
params={'my_param':"SCRM_Contact_af0912"},
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
|
||||
|
||||
file_SCRM_Contact_bf0912 = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='file_SCRM_Contact_bf0912',
|
||||
command='python /data/airflow/bin/FILELOD.py {{ params.my_param }} {{ ds_nodash }} >>/data/airflow/logs/file_load/file_load_{{ds_nodash}}.log 2>&1 ',
|
||||
params={'my_param':"SCRM_Contact_bf0912"},
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
|
||||
|
||||
livechat_6381 = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='livechat_6381',
|
||||
command='/data/airflow/etl/SA/run_sa.sh {{ ds_nodash }} {{ params.my_param }} >>/data/airflow/logs/run_psql_{{ds_nodash}}.log 2>&1 ',
|
||||
params={'my_param':"S98_S_livechat"},
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
|
||||
scrm_contact_af0912_6333 = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='scrm_contact_af0912_6333',
|
||||
command='/data/airflow/etl/SA/run_sa.sh {{ ds_nodash }} {{ params.my_param }} >>/data/airflow/logs/run_psql_{{ds_nodash}}.log 2>&1 ',
|
||||
params={'my_param':"S98_S_scrm_contact_af0912"},
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
|
||||
scrm_contact_update_af0912_6448 = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='scrm_contact_update_af0912_6448',
|
||||
command='/data/airflow/etl/SA/run_sa.sh {{ ds_nodash }} {{ params.my_param }} >>/data/airflow/logs/run_psql_{{ds_nodash}}.log 2>&1 ',
|
||||
params={'my_param':"S98_S_scrm_contact_update_af0912"},
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
|
||||
scrm_contact_merge_af0912_7975 = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='scrm_contact_merge_af0912_7975',
|
||||
command='/data/airflow/etl/SA/run_sa.sh {{ ds_nodash }} {{ params.my_param }} >>/data/airflow/logs/run_psql_{{ds_nodash}}.log 2>&1 ',
|
||||
params={'my_param':"S98_S_scrm_contact_merge_af0912"},
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
|
||||
scrm_contact_bf0912_6949 = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='scrm_contact_bf0912_6949',
|
||||
command='/data/airflow/etl/SA/run_sa.sh {{ ds_nodash }} {{ params.my_param }} >>/data/airflow/logs/run_psql_{{ds_nodash}}.log 2>&1 ',
|
||||
params={'my_param':"S98_S_scrm_contact_bf0912"},
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
|
||||
T01_SCRM_CONTACT = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='T01_SCRM_CONTACT',
|
||||
command='/data/airflow/etl/PDM/run_sa.sh {{ ds_nodash }} {{params.my_param}} >>/data/airflow/logs/run_tpt_{{ds_nodash}}.log 2>&1 ',
|
||||
params={'my_param':"T01_SCRM_CONTACT_agi"},
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
file_Udesk_record = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='file_Udesk_record',
|
||||
command='python /data/airflow/bin/FILELOD.py {{ params.my_param }} {{ ds_nodash }} >>/data/airflow/logs/file_load/file_load_{{ds_nodash}}.log 2>&1 ',
|
||||
params={'my_param':"Udesk_record"},
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
|
||||
|
||||
file_CRM_Raw_Leads = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='file_CRM_Raw_Leads',
|
||||
command='python /data/airflow/bin/FILELOD.py {{ params.my_param }} {{ ds_nodash }} >>/data/airflow/logs/file_load/file_load_{{ds_nodash}}.log 2>&1 ',
|
||||
params={'my_param':"CRM_Raw_Leads"},
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
|
||||
|
||||
file_scrm_leads_bf0912 = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='file_scrm_leads_bf0912',
|
||||
command='python /data/airflow/bin/FILELOD.py {{ params.my_param }} {{ ds_nodash }} >>/data/airflow/logs/file_load/file_load_{{ds_nodash}}.log 2>&1 ',
|
||||
params={'my_param':"scrm_leads_bf0912"},
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
|
||||
|
||||
file_scrm_leads_af0912 = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='file_scrm_leads_af0912',
|
||||
command='python /data/airflow/bin/FILELOD.py {{ params.my_param }} {{ ds_nodash }} >>/data/airflow/logs/file_load/file_load_{{ds_nodash}}.log 2>&1 ',
|
||||
params={'my_param':"scrm_leads_af0912"},
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
|
||||
|
||||
udesk_record_3768 = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='udesk_record_3768',
|
||||
command='/data/airflow/etl/SA/run_sa.sh {{ ds_nodash }} {{ params.my_param }} >>/data/airflow/logs/run_psql_{{ds_nodash}}.log 2>&1 ',
|
||||
params={'my_param':"S98_S_udesk_record"},
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
|
||||
scrm_leads_bf0912_508 = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='scrm_leads_bf0912_508',
|
||||
command='/data/airflow/etl/SA/run_sa.sh {{ ds_nodash }} {{ params.my_param }} >>/data/airflow/logs/run_psql_{{ds_nodash}}.log 2>&1 ',
|
||||
params={'my_param':"S98_S_scrm_leads_bf0912"},
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
|
||||
scrm_leads_af0912_5813 = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='scrm_leads_af0912_5813',
|
||||
command='/data/airflow/etl/SA/run_sa.sh {{ ds_nodash }} {{ params.my_param }} >>/data/airflow/logs/run_psql_{{ds_nodash}}.log 2>&1 ',
|
||||
params={'my_param':"S98_S_scrm_leads_af0912"},
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
|
||||
crm_raw_leads_6024 = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='crm_raw_leads_6024',
|
||||
command='/data/airflow/etl/SA/run_sa.sh {{ ds_nodash }} {{ params.my_param }} >>/data/airflow/logs/run_psql_{{ds_nodash}}.log 2>&1 ',
|
||||
params={'my_param':"S98_S_crm_raw_leads"},
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
|
||||
t01_scrm_contact_his = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='t01_scrm_contact_his',
|
||||
command='/data/airflow/etl/PDM/run_sa.sh {{ ds_nodash }} {{params.my_param}} >>/data/airflow/logs/run_tpt_{{ds_nodash}}.log 2>&1 ',
|
||||
params={'my_param':"t01_scrm_contact_his_agi"},
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
t01_scrm_contact_update = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='t01_scrm_contact_update',
|
||||
command='/data/airflow/etl/PDM/run_sa.sh {{ ds_nodash }} {{params.my_param}} >>/data/airflow/logs/run_tpt_{{ds_nodash}}.log 2>&1 ',
|
||||
params={'my_param':"t01_scrm_contact_update_agi"},
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
t01_scrm_contact_merge = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='t01_scrm_contact_merge',
|
||||
command='/data/airflow/etl/PDM/run_sa.sh {{ ds_nodash }} {{params.my_param}} >>/data/airflow/logs/run_tpt_{{ds_nodash}}.log 2>&1 ',
|
||||
params={'my_param':"t01_scrm_contact_merge_agi"},
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
t01_livechat_record = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='t01_livechat_record',
|
||||
command='/data/airflow/etl/PDM/run_sa.sh {{ ds_nodash }} {{params.my_param}} >>/data/airflow/logs/run_tpt_{{ds_nodash}}.log 2>&1 ',
|
||||
params={'my_param':"t01_livechat_record_agi"},
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
china_city_4536 = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='china_city_4536',
|
||||
command='/data/airflow/etl/SA/run_sa.sh {{ ds_nodash }} {{ params.my_param }} >>/data/airflow/logs/run_psql_{{ds_nodash}}.log 2>&1 ',
|
||||
params={'my_param':"S98_S_china_city"},
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
|
||||
country_cde_3310 = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='country_cde_3310',
|
||||
command='/data/airflow/etl/SA/run_sa.sh {{ ds_nodash }} {{ params.my_param }} >>/data/airflow/logs/run_psql_{{ds_nodash}}.log 2>&1 ',
|
||||
params={'my_param':"S98_S_country_cde"},
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
|
||||
file_china_city = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='file_china_city',
|
||||
command='python /data/airflow/bin/FILELOD.py {{ params.my_param }} {{ ds_nodash }} >>/data/airflow/logs/file_load/file_load_{{ds_nodash}}.log 2>&1 ',
|
||||
params={'my_param':"china_city"},
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
|
||||
|
||||
file_country_cde = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='file_country_cde',
|
||||
command='python /data/airflow/bin/FILELOD.py {{ params.my_param }} {{ ds_nodash }} >>/data/airflow/logs/file_load/file_load_{{ds_nodash}}.log 2>&1 ',
|
||||
params={'my_param':"country_cde"},
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
|
||||
|
||||
t01_crm_raw_leads = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='t01_crm_raw_leads',
|
||||
command='/data/airflow/etl/PDM/run_sa.sh {{ ds_nodash }} {{params.my_param}} >>/data/airflow/logs/run_tpt_{{ds_nodash}}.log 2>&1 ',
|
||||
params={'my_param':"t01_crm_raw_leads_agi"},
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
t00_country_info = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='t00_country_info',
|
||||
command='/data/airflow/etl/PDM/run_sa.sh {{ ds_nodash }} {{params.my_param}} >>/data/airflow/logs/run_tpt_{{ds_nodash}}.log 2>&1 ',
|
||||
params={'my_param':"t00_country_info_agi"},
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
t00_china_city_info = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='t00_china_city_info',
|
||||
command='/data/airflow/etl/PDM/run_sa.sh {{ ds_nodash }} {{params.my_param}} >>/data/airflow/logs/run_tpt_{{ds_nodash}}.log 2>&1 ',
|
||||
params={'my_param':"t00_china_city_info_agi"},
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
t01_scrm_leads_his = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='t01_scrm_leads_his',
|
||||
command='/data/airflow/etl/PDM/run_sa.sh {{ ds_nodash }} {{params.my_param}} >>/data/airflow/logs/run_tpt_{{ds_nodash}}.log 2>&1 ',
|
||||
params={'my_param':"t01_scrm_leads_his_agi"},
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
t01_scrm_leads = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='t01_scrm_leads',
|
||||
command='/data/airflow/etl/PDM/run_sa.sh {{ ds_nodash }} {{params.my_param}} >>/data/airflow/logs/run_tpt_{{ds_nodash}}.log 2>&1 ',
|
||||
params={'my_param':"t01_scrm_leads_agi"},
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
file_Tk01 >> livechat_6381
|
||||
file_Merge_af0912 >> scrm_contact_merge_af0912_7975
|
||||
file_SCRM_Contact_bf0912 >> scrm_contact_bf0912_6949
|
||||
file_SCRM_Contact_af0912 >> scrm_contact_af0912_6333
|
||||
file_Update_af0912 >> scrm_contact_update_af0912_6448
|
||||
scrm_contact_af0912_6333 >> T01_SCRM_CONTACT
|
||||
file_Udesk_record >> udesk_record_3768
|
||||
file_scrm_leads_bf0912 >> scrm_leads_bf0912_508
|
||||
file_scrm_leads_af0912 >> scrm_leads_af0912_5813
|
||||
file_CRM_Raw_Leads >> crm_raw_leads_6024
|
||||
scrm_contact_bf0912_6949 >> t01_scrm_contact_his
|
||||
scrm_contact_update_af0912_6448 >> t01_scrm_contact_update
|
||||
scrm_contact_merge_af0912_7975 >> t01_scrm_contact_merge
|
||||
livechat_6381 >> t01_livechat_record
|
||||
file_country_cde >> country_cde_3310
|
||||
file_china_city >> china_city_4536
|
||||
crm_raw_leads_6024 >> t01_crm_raw_leads
|
||||
country_cde_3310 >> t00_country_info
|
||||
china_city_4536 >> t00_china_city_info
|
||||
scrm_leads_bf0912_508 >> t01_scrm_leads_his
|
||||
scrm_leads_af0912_5813 >> t01_scrm_leads
|
||||
t01_scrm_leads >> task_failed
|
Loading…
Reference in New Issue