Altinity / clickhouse-sink-connector

Replicate data from MySQL, Postgres and MongoDB to ClickHouse®
https://www.altinity.com
Apache License 2.0
234 stars 54 forks source link

validate if CREATE TRIGGER DDL is ignored with regex #916

Open subkanthi opened 1 week ago

subkanthi commented 1 week ago
subkanthi commented 1 week ago

Because its a multi-line DDL the regex need to match the entire DDL.

/CREATE\s+TRIGGER\s+\w+\s+BEFORE\s+INSERT\s+ON\s+\w+\s+FOR\s+EACH\s+ROW\s+PRECEDES\s+\w+\s+SET\s+(.|\s)+?;/gm
CREATE TRIGGER ins_transaction BEFORE INSERT ON account
       FOR EACH ROW PRECEDES ins_sum
       SET
       @deposits = @deposits + IF(NEW.amount>0,NEW.amount,0),
       @withdrawals = @withdrawals + IF(NEW.amount<0,-NEW.amount,0);
CREATE TABLE test.account (
    id INT AUTO_INCREMENT PRIMARY KEY,
    account_number VARCHAR(20) NOT NULL,
    amount DECIMAL(10, 2) NOT NULL
);
subkanthi commented 1 week ago

Debezium translates the DDL to the following format


CREATE DEFINER=`root`@`%` TRIGGER ins_transaction BEFORE INSERT ON account
       FOR EACH ROW
       SET
       @deposits = @deposits + IF(NEW.amount>0,NEW.amount,0),
       @withdrawals = @withdrawals + IF(NEW.amount<0,-NEW.amount,0)```
subkanthi commented 1 week ago

Added unit test in #896

regex that multiple lines work

^CREATE\s+DEFINER*.*\n*.*\n*.*\n*.*\n*.*