Closed ddusen closed 4 years ago
It seems that there is class conflicts in your class path. Please check whether there is multiple flink-cdc-connectors with different version.
flink-sql-connector-mysql-cdc-1.0.0.jar
和 flink-sql-connector-postgres-cdc-1.1.0-SNAPSHOT.jar
是有冲突的。
原来是 mysql-cdc 和 postgres-cdc-1.1.0 有冲突。 未来的版本会解决这个问题嘛?
之后可能会同时使用 mysql 和 postgres
@Sdu0 我的意思是,你这两个 jar 的版本不一致啊。版本一致就没问题了。
我明白了,多谢 👍
Flink SQL
'connector' = 'postgres-cdc', 'hostname' = '127.0.0.1', 'port' = '5432', 'username' = 'postgres', 'password' = 'postgres', 'database-name' = 'seesaw_boh_test_report', 'schema-name' = 'public' , 'table-name' = 'store_caches', 'debezium.slot.name' = 'store_caches' );
create table sales_ticket_amounts ( id bigint primary key, partner_id bigint , scope_id bigint , bus_date date , bus_date_week date , bus_date_month date , bus_date_year date , store_id bigint , eticket_id bigint , channel_id bigint , channel_name varchar(50) , order_type varchar(15) , order_type_name varchar(15) , order_time timestamp , refunded boolean , gross_amount numeric(38, 16) , net_amount numeric(38, 16) , discount_amount numeric(38, 16) , tip numeric(38, 16) , package_fee numeric(38, 16) , delivery_fee numeric(38, 16) , service_fee numeric(38, 16) , tax_fee numeric(38, 16) , other_fee numeric(38, 16) , pay_amount numeric(38, 16) , rounding numeric(38, 16) , overflow_amount numeric(38, 16) , change_amount numeric(38, 16) , product_count bigint , accessory_count bigint , eticket_count bigint , created TIMESTAMP
) WITH (
'connector' = 'postgres-cdc', 'hostname' = '127.0.0.1', 'port' = '5432', 'username' = 'postgres', 'password' = 'postgres', 'database-name' = 'seesaw_boh_test_report', 'schema-name' = 'public' , 'table-name' = 'sales_ticket_amounts', 'debezium.slot.name' = 'sales_ticket_amounts' );
--目标表
create table store_sales ( bus_date date, store_id bigint, gross_amount numeric(38, 16), net_amount numeric(38, 16), discount_amount numeric(38, 16), tip numeric(38, 16), package_fee numeric(38, 16), delivery_fee numeric(38, 16), service_fee numeric(38, 16), tax_fee numeric(38, 16), other_fee numeric(38, 16), pay_amount numeric(38, 16), rounding numeric(38, 16), overflow_amount numeric(38, 16), change_amount numeric(38, 16), order_count bigint, product_count bigint, accessory_count bigint, gross_amount_returned numeric(38, 16), net_amount_returned numeric(38, 16), discount_amount_returned numeric(38, 16), tip_returned numeric(38, 16), package_fee_returned numeric(38, 16), delivery_fee_returned numeric(38, 16), service_fee_returned numeric(38, 16), tax_fee_returned numeric(38, 16), other_fee_returned numeric(38, 16), pay_amount_returned numeric(38, 16), rounding_returned numeric(38, 16), overflow_amount_returned numeric(38, 16), change_amount_returned numeric(38, 16), order_count_returned bigint, PRIMARY KEY(bus_date, store_id) NOT ENFORCED ) WITH (
'connector' = 'jdbc', 'url' = 'jdbc:postgresql://127.0.0.1:5432/seesaw_boh_test_report', 'username' = 'postgres', 'password' = 'postgres' , 'table-name' = 'store_sales' )
--Flink Job INSERT INTO store_sales( bus_date,store_id,gross_amount,net_amount,discount_amount,tip,package_fee,delivery_fee, service_fee,tax_fee,other_fee,pay_amount,rounding,overflow_amount,change_amount,order_count, product_count,accessory_count,gross_amount_returned,net_amount_returned,discount_amount_returned, tip_returned,package_fee_returned,delivery_fee_returned,service_fee_returned,tax_fee_returned, other_fee_returned,pay_amount_returned,rounding_returned,overflow_amount_returned,change_amount_returned, order_count_returned ) SELECT sales_ticket_amounts.bus_date AS bus_date, store_caches.id AS store_id, SUM(CASE WHEN refunded THEN 0 ELSE gross_amount END) AS gross_amount, SUM(net_amount) AS net_amount, SUM(CASE WHEN refunded THEN 0 ELSE discount_amount END) AS discount_amount, SUM(CASE WHEN refunded THEN 0 ELSE tip END) AS tip, SUM(CASE WHEN refunded THEN 0 ELSE package_fee END) AS package_fee, SUM(CASE WHEN refunded THEN 0 ELSE delivery_fee END) AS delivery_fee, SUM(CASE WHEN refunded THEN 0 ELSE service_fee END) AS service_fee, SUM(CASE WHEN refunded THEN 0 ELSE tax_fee END) AS tax_fee, SUM(CASE WHEN refunded THEN 0 ELSE other_fee END) AS other_fee, SUM(CASE WHEN refunded THEN 0 ELSE pay_amount END) AS pay_amount, SUM(CASE WHEN refunded THEN 0 ELSE rounding END) AS rounding, SUM(CASE WHEN refunded THEN 0 ELSE overflow_amount END) AS overflow_amount, SUM(CASE WHEN refunded THEN 0 ELSE change_amount END) AS change_amount, SUM(CASE WHEN refunded THEN 0 ELSE eticket_count END) AS order_count, SUM(CASE WHEN refunded THEN 0 ELSE product_count END) AS product_count, SUM(CASE WHEN refunded THEN 0 ELSE accessory_count END) AS accessory_count, SUM(CASE WHEN refunded THEN gross_amount ELSE 0 END) AS gross_amount_returned, SUM(CASE WHEN refunded THEN net_amount ELSE 0 END) AS net_amount_returned, SUM(CASE WHEN refunded THEN discount_amount ELSE 0 END) AS discount_amount_returned, SUM(CASE WHEN refunded THEN tip ELSE 0 END) AS tip_returned, SUM(CASE WHEN refunded THEN package_fee ELSE 0 END) AS package_fee_returned, SUM(CASE WHEN refunded THEN delivery_fee ELSE 0 END) AS delivery_fee_returned, SUM(CASE WHEN refunded THEN service_fee ELSE 0 END) AS service_fee_returned, SUM(CASE WHEN refunded THEN tax_fee ELSE 0 END) AS tax_fee_returned, SUM(CASE WHEN refunded THEN other_fee ELSE 0 END) AS other_fee_returned, SUM(CASE WHEN refunded THEN pay_amount ELSE 0 END) AS pay_amount_returned, SUM(CASE WHEN refunded THEN rounding ELSE 0 END) AS rounding_returned, SUM(CASE WHEN refunded THEN overflow_amount ELSE 0 END) AS overflow_amount_returned, SUM(CASE WHEN refunded THEN change_amount ELSE 0 END) AS change_amount_returned, SUM(CASE WHEN refunded THEN eticket_count ELSE 0 END) AS order_count_returned FROM sales_ticket_amounts LEFT JOIN store_caches ON sales_ticket_amounts.store_id = store_caches.id GROUP BY sales_ticket_amounts.bus_date, store_caches.id
flink-sql-connector-postgres-cdc-1.1.0-SNAPSHOT.jar flink-format-changelog-json-1.0.0.jar