Open subkanthi opened 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
);
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)```
Added unit test in #896
regex that multiple lines work
^CREATE\s+DEFINER*.*\n*.*\n*.*\n*.*\n*.*
CREATE TRIGGER
MySQL DDL are not translated to clickhouse.CREATE TRIGGER
DDL.