Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

validate if CREATE TRIGGER DDL is ignored with regex #916

Open
subkanthi opened this issue Nov 13, 2024 · 3 comments
Open

validate if CREATE TRIGGER DDL is ignored with regex #916

subkanthi opened this issue Nov 13, 2024 · 3 comments
Assignees
Labels
dev-complete Development completed qa-verified label to mark issues that were verified by QA
Milestone

Comments

@subkanthi
Copy link
Collaborator

  • Currently CREATE TRIGGER MySQL DDL are not translated to clickhouse.
  • For the user using the Ignore DDL based on regex. #895 feature they should be able to ignore the CREATE TRIGGER DDL.
@subkanthi subkanthi added this to the 2.5.0 milestone Nov 13, 2024
@subkanthi subkanthi self-assigned this Nov 13, 2024
@subkanthi
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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 subkanthi added the dev-complete Development completed label Nov 13, 2024
@subkanthi
Copy link
Collaborator Author

Added unit test in #896

regex that multiple lines work

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

@Selfeer Selfeer added the qa-verified label to mark issues that were verified by QA label Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dev-complete Development completed qa-verified label to mark issues that were verified by QA
Projects
None yet
Development

No branches or pull requests

2 participants