USE CATALOG flink-test
;
CREATE TEMPORARY TABLE flink_datagen_sourcet_temp
(
dep_id INTEGER
,cus_id INTEGER
,bra_id INTEGER
,dept_id INTEGER
,status INTEGER
,PRIMARY KEY (dep_id
) NOT ENFORCED
)
COMMENT ‘test’
WITH (
‘connector’ = ‘mysql-cdc’
,’hostname’ = ‘pc-uf6he30o2g7yb74k1.rwlb.rds.aliyuncs.com’
,’port’ = ‘3306’
,’username’ = ‘zhimei_mysql’
,’password’ = ‘zhimei_service1@#!&’
,’database-name’ = ‘flink_test’
,’table-name’ = ‘by_crm_cart_deposit’
)
;
CREATE TEMPORARY TABLE flink_finance_output_print
(
id INTEGER
,dep_id INTEGER
,cus_id INTEGER
,city_id INTEGER
,bra_id INTEGER
,bra_name VARCHAR
)
WITH (
‘connector’ = ‘print’, ‘logger’ = ‘true’
)
;
BEGIN STATEMENT SET
;
INSERT INTO flink_finance_output
SELECT
0 AS id
,cd.dep_id
,cd.cus_id
,dd.city_id
,cd.bra_id
,bb.bra_name
FROM flink_datagen_sourcet_temp cd
LEFT JOIN by_crm_dept dd
ON dd.dept_id = cd.dept_id
left join by_crm_brand bb
on cd.bra_id = bb.bra_id
WHERE dd.biz_id = 539
and cd.status 3
;
INSERT INTO flink_finance_output_print
SELECT
0 AS id
,cd.dep_id
,cd.cus_id
,dd.city_id
,cd.bra_id
,bb.bra_name
FROM flink_datagen_sourcet_temp cd
LEFT JOIN by_crm_dept dd
ON dd.dept_id = cd.dept_id
left join by_crm_brand bb
on cd.bra_id = bb.bra_id
WHERE dd.biz_id = 539
and cd.status 3
;
END
;