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

[Improve](mysqlSync)Add the configuration of whether to synchronize the default value #152

Merged
merged 7 commits into from Jul 21, 2023

Conversation

DongLiang-0
Copy link
Contributor

@DongLiang-0 DongLiang-0 commented Jun 26, 2023

Proposed changes

At present, when the mysql database sync to doris , there is a default value in the field, but the actual data is null, the data cannot maintain consistency.

Like: when mysql schema has a default value and the insertion is null, the data synchronized to doris uses the default value.

CREATE TABLE `test_sink` (
  `id` int NOT NULL,
  `name` varchar(50) DEFAULT 'test_default',
  `age` int DEFAULT '10000',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci

insert into test_sink (id,name,age) values(6, null, 666);
insert into test_sink (id,name,age) values(5, 'zhaoliu', null);

Configure --ignore-default-value, the default value will not be synchronized, otherwise it will be synchronized.

Problem Summary:

Describe the overview of changes.

Checklist(Required)

  1. Does it affect the original behavior: (Yes/No/I Don't know)
  2. Has unit tests been added: (Yes/No/No Need)
  3. Has document been added or modified: (Yes/No/No Need)
  4. Does it need to update dependencies: (Yes/No)
  5. Are there any changes that cannot be rolled back: (Yes/No)

Further comments

If this is a relatively large or complex change, kick off the discussion at dev@doris.apache.org by explaining why you chose the solution you did and what alternatives you considered, etc...

@@ -57,6 +57,8 @@ private static void createMySQLSyncDatabase(String[] opArgs) throws Exception {
String tableSuffix = params.get("table-suffix");
String includingTables = params.get("including-tables");
String excludingTables = params.get("excluding-tables");
boolean ignoreDefaultValue =
Boolean.parseBoolean(params.get("ignore-default-value", "false"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

params.has is better?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your suggestion, I have fixed it.

Copy link
Member

@JNSimba JNSimba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@JNSimba JNSimba merged commit 4038842 into apache:master Jul 21, 2023
4 checks passed
@Memory5210

This comment was marked as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants