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](schemaChange)schema change ddl supports multi-column changes, synchronous defaults #167

Merged
merged 2 commits into from Aug 3, 2023

Conversation

DongLiang-0
Copy link
Contributor

@DongLiang-0 DongLiang-0 commented Aug 2, 2023

Proposed changes

The old schema change need to use regular expressions to match, resulting in comparison limitations.

The new schema change:

  1. supports multi-column changes
  2. support for synchronous defaults.

MySQL multi-table import enables new schema change only by configuring --use-new-schema-change, oracle does not currently support

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...

@DongLiang-0 DongLiang-0 changed the title [Improve](schemaChange)schema change ddl supports synchronizing default and comment [Improve](schemaChange)schema change ddl supports multi-column changes, rename column, synchronous defaults Aug 2, 2023
@@ -245,7 +245,7 @@ under the License.
<dependency>
<groupId>com.ververica</groupId>
<artifactId>flink-sql-connector-mysql-cdc</artifactId>
<version>2.3.0</version>
<version>2.4.1</version>
Copy link
Member

Choose a reason for hiding this comment

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

Will 2.4.1 conflict with oracle2.3.0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This problem occurs when running the CdcOraclelSyncDatabaseCase class alone

return null;
}
// Due to historical reasons, doris needs to add quotes to the default value of the new column
if (Pattern.matches("['\"].*?['\"]", defaultValue)) {
Copy link
Member

@JNSimba JNSimba Aug 2, 2023

Choose a reason for hiding this comment

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

It is recommended to write an example on the comments

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Of course, I've added.

Comment on lines +35 to +36
public static final String ADD_DDL = "ALTER TABLE %s ADD COLUMN %s %s";
public static final String DROP_DDL = "ALTER TABLE %s DROP COLUMN %s";
Copy link
Member

Choose a reason for hiding this comment

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

only saw add and drop column, how is rename implemented?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rename is currently not supported, the rename statement will be filtered, and doris will not execute it.

return success;
}

private List<String> extractDDLList(JsonNode record) throws JsonProcessingException {
Copy link
Member

Choose a reason for hiding this comment

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

Need to add unit tests

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 changed.

@@ -277,6 +371,68 @@ private String authHeader() {
return "Basic " + new String(Base64.encodeBase64((dorisOptions.getUsername() + ":" + dorisOptions.getPassword()).getBytes(StandardCharsets.UTF_8)));
}

private void fillOriginSchema(JsonNode columns) {
Copy link
Member

Choose a reason for hiding this comment

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

the same as above

@@ -71,8 +71,9 @@ public static void main(String[] args) throws Exception{
String includingTables = "test.*";
String excludingTables = "";
boolean ignoreDefaultValue = false;
boolean useNewSchemaChange = false;
Copy link
Member

Choose a reason for hiding this comment

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

Can schema change be execute in oracle?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oracle currently does not support.

@DongLiang-0 DongLiang-0 changed the title [Improve](schemaChange)schema change ddl supports multi-column changes, rename column, synchronous defaults [Improve](schemaChange)schema change ddl supports multi-column changes, synchronous defaults Aug 3, 2023
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 14be15b into apache:master Aug 3, 2023
8 checks passed
@icchux
Copy link

icchux commented Nov 22, 2023

Hi, I found a problem during testing. Please confirm it
When the program starts for the first time, firstSchemeChange==true will initialize the originFieldSchema Map, but if the number of fields in updateFiledSchema is the same as that in originFieldSchema Map, no subsequent ddl changes will be made
5c074cb3-314c-4774-82a4-ddeb2f2dc7fa

@JNSimba JNSimba mentioned this pull request Nov 30, 2023
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