You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by GitBox <gi...@apache.org> on 2022/12/28 02:20:28 UTC
[GitHub] [inlong] chyueyi opened a new pull request, #7079: [INLONG-7076] [sort-connector-jdbc] Add multi table sink for MySQL
chyueyi opened a new pull request, #7079:
URL: https://github.com/apache/inlong/pull/7079
## Prepare a Pull Request
- [[INLONG-7076] [sort-connector-jdbc] Add multi table sink for MySQL](https://github.com/apache/inlong/issues/7076)
- Fixes #XYZ
### Motivation
- Users want to real time sync multi-tables data in mongoDB、KAFKA etc to MySql or other JDBC based databases in many case. We need multi table-sink connector for MySql.
- Based on flink-connector-jdbc, sort-connector-jdbc can sink data to MySql in two formats: canal-json.
### Modifications
- Add multi table sink for MySQL
- add MySQLRowConverter, MySQLDialect
- modify JdbcMultiBatchingOutputFormat and AbstractJdbcRowConverter to Support Mysql data type
### Verifying this change
*(Please pick either of the following options)*
- [ ] This change is a trivial rework/code cleanup without any test coverage.
- [ ] This change is already covered by existing tests, such as:
*(please describe tests)*
- [ ] This change added tests and can be verified as follows:
*(example:)*
```sql
CREATE TABLE cdc_mysql_source (
`data` BYTES METADATA FROM 'meta.data_canal' VIRTUAL
) WITH (
'inlong.metric.labels' = 'groupId=1&streamId=1&nodeId=1',
'migrate-all' = 'true',
'connector' = 'mysql-cdc-inlong',
'scan.incremental.snapshot.enabled' = 'false',
'hostname' = 'localhost',
'database-name' = 'test',
'server-time-zone' = 'Asia/Shanghai',
'username' = '****',
'password' = '****',
'table-name' = 'test\.[\s\S]*'
);
CREATE TABLE cdc_mysql_sink (
`data` BYTES
)WITH (
'connector' = 'jdbc-inlong',
'url' = 'jdbc:mysql://localhost:3306',
'username' = '****',
'password' = '****',
'table-name' = 'test',
'sink.multiple.enable' = 'true',
'sink.multiple.schema-update.policy' = 'TRY_IT_BEST',
'sink.multiple.format' = 'canal-json',
'sink.multiple.database-pattern' = 'test2',
'sink.multiple.schema-pattern' = '',
'sink.multiple.table-pattern' = '${table}'
);
insert into cdc_mysql_sink select * from cdc_mysql_source;
```
### Documentation
- Does this pull request introduce a new feature? (yes / no)
- If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)
- If a feature is not applicable for documentation, explain why?
- If a feature is not documented yet in this PR, please create a follow-up issue for adding the documentation
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [inlong] dockerzhang merged pull request #7079: [INLONG-7076][Sort] Add multi table sink for MySQL
Posted by GitBox <gi...@apache.org>.
dockerzhang merged PR #7079:
URL: https://github.com/apache/inlong/pull/7079
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [inlong] chyueyi commented on a diff in pull request #7079: [INLONG-7076][Sort] Add multi table sink for MySQL
Posted by GitBox <gi...@apache.org>.
chyueyi commented on code in PR #7079:
URL: https://github.com/apache/inlong/pull/7079#discussion_r1058858337
##########
inlong-sort/sort-connectors/jdbc/src/main/java/org/apache/inlong/sort/jdbc/internal/JdbcMultiBatchingOutputFormat.java:
##########
@@ -399,14 +420,44 @@ protected GenericRowData generateRecord(RowType rowType, Map<String, String> fie
record.setField(i, Double.valueOf(fieldValue));
break;
case TIME_WITHOUT_TIME_ZONE:
- case TIMESTAMP_WITHOUT_TIME_ZONE:
+ // case TIMESTAMP_WITHOUT_TIME_ZONE:
Review Comment:
OK,fixed it @kuansix
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [inlong] kuansix commented on a diff in pull request #7079: [INLONG-7076][Sort] Add multi table sink for MySQL
Posted by GitBox <gi...@apache.org>.
kuansix commented on code in PR #7079:
URL: https://github.com/apache/inlong/pull/7079#discussion_r1058784618
##########
inlong-sort/sort-connectors/jdbc/src/main/java/org/apache/inlong/sort/jdbc/internal/JdbcMultiBatchingOutputFormat.java:
##########
@@ -399,14 +420,44 @@ protected GenericRowData generateRecord(RowType rowType, Map<String, String> fie
record.setField(i, Double.valueOf(fieldValue));
break;
case TIME_WITHOUT_TIME_ZONE:
- case TIMESTAMP_WITHOUT_TIME_ZONE:
+ // case TIMESTAMP_WITHOUT_TIME_ZONE:
case INTERVAL_DAY_TIME:
TimestampData timestampData = TimestampData.fromEpochMillis(Long.valueOf(fieldValue));
record.setField(i, timestampData);
break;
case BINARY:
record.setField(i, Arrays.toString(fieldValue.getBytes(StandardCharsets.UTF_8)));
break;
+
Review Comment:
Can L431-L460 also apply to CK、GP、Oracle、PG、SqlServer、TDSQL ?
##########
inlong-sort/sort-connectors/jdbc/src/main/java/org/apache/inlong/sort/jdbc/internal/JdbcMultiBatchingOutputFormat.java:
##########
@@ -399,14 +420,44 @@ protected GenericRowData generateRecord(RowType rowType, Map<String, String> fie
record.setField(i, Double.valueOf(fieldValue));
break;
case TIME_WITHOUT_TIME_ZONE:
- case TIMESTAMP_WITHOUT_TIME_ZONE:
+ // case TIMESTAMP_WITHOUT_TIME_ZONE:
Review Comment:
remove it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [inlong] chyueyi commented on a diff in pull request #7079: [INLONG-7076][Sort] Add multi table sink for MySQL
Posted by GitBox <gi...@apache.org>.
chyueyi commented on code in PR #7079:
URL: https://github.com/apache/inlong/pull/7079#discussion_r1058858944
##########
inlong-sort/sort-connectors/jdbc/src/main/java/org/apache/inlong/sort/jdbc/internal/JdbcMultiBatchingOutputFormat.java:
##########
@@ -399,14 +420,44 @@ protected GenericRowData generateRecord(RowType rowType, Map<String, String> fie
record.setField(i, Double.valueOf(fieldValue));
break;
case TIME_WITHOUT_TIME_ZONE:
- case TIMESTAMP_WITHOUT_TIME_ZONE:
+ // case TIMESTAMP_WITHOUT_TIME_ZONE:
case INTERVAL_DAY_TIME:
TimestampData timestampData = TimestampData.fromEpochMillis(Long.valueOf(fieldValue));
record.setField(i, timestampData);
break;
case BINARY:
record.setField(i, Arrays.toString(fieldValue.getBytes(StandardCharsets.UTF_8)));
break;
+
Review Comment:
Didn't test for these databases.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [inlong] gong commented on pull request #7079: [INLONG-7076][Sort] Add multi table sink for MySQL
Posted by GitBox <gi...@apache.org>.
gong commented on PR #7079:
URL: https://github.com/apache/inlong/pull/7079#issuecomment-1366414528
@kuansix please help to review it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [inlong] gong commented on a diff in pull request #7079: [INLONG-7076][Sort] Add multi table sink for MySQL
Posted by GitBox <gi...@apache.org>.
gong commented on code in PR #7079:
URL: https://github.com/apache/inlong/pull/7079#discussion_r1058077632
##########
inlong-sort/sort-connectors/jdbc/src/main/java/org/apache/inlong/sort/jdbc/converter/AbstractJdbcRowConverter.java:
##########
@@ -25,11 +25,7 @@
import org.apache.flink.table.data.RowData;
import org.apache.flink.table.data.StringData;
import org.apache.flink.table.data.TimestampData;
-import org.apache.flink.table.types.logical.DecimalType;
-import org.apache.flink.table.types.logical.LogicalType;
-import org.apache.flink.table.types.logical.LogicalTypeRoot;
-import org.apache.flink.table.types.logical.RowType;
-import org.apache.flink.table.types.logical.TimestampType;
+import org.apache.flink.table.types.logical.*;
Review Comment:
you need use codestyle of inlong, not to use `.*`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [inlong] chyueyi commented on pull request #7079: [INLONG-7076][Sort] Add multi table sink for MySQL
Posted by GitBox <gi...@apache.org>.
chyueyi commented on PR #7079:
URL: https://github.com/apache/inlong/pull/7079#issuecomment-1366411665
@gong OK, I've modified it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [inlong] gong commented on a diff in pull request #7079: [INLONG-7076][Sort] Add multi table sink for MySQL
Posted by GitBox <gi...@apache.org>.
gong commented on code in PR #7079:
URL: https://github.com/apache/inlong/pull/7079#discussion_r1058074563
##########
inlong-sort/sort-connectors/jdbc/src/main/java/org/apache/inlong/sort/jdbc/table/JdbcDialects.java:
##########
@@ -18,7 +18,8 @@
package org.apache.inlong.sort.jdbc.table;
import org.apache.flink.connector.jdbc.dialect.JdbcDialect;
-import org.apache.flink.connector.jdbc.dialect.MySQLDialect;
+//import org.apache.flink.connector.jdbc.dialect.MySQLDialect;
+import org.apache.inlong.sort.jdbc.dialect.MySQLDialect;
Review Comment:
remove `//import org.apache.flink.connector.jdbc.dialect.MySQLDialect;`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [inlong] kuansix commented on a diff in pull request #7079: [INLONG-7076][Sort] Add multi table sink for MySQL
Posted by GitBox <gi...@apache.org>.
kuansix commented on code in PR #7079:
URL: https://github.com/apache/inlong/pull/7079#discussion_r1059220070
##########
inlong-sort/sort-connectors/jdbc/src/main/java/org/apache/inlong/sort/jdbc/internal/JdbcMultiBatchingOutputFormat.java:
##########
@@ -399,14 +420,44 @@ protected GenericRowData generateRecord(RowType rowType, Map<String, String> fie
record.setField(i, Double.valueOf(fieldValue));
break;
case TIME_WITHOUT_TIME_ZONE:
- case TIMESTAMP_WITHOUT_TIME_ZONE:
+ // case TIMESTAMP_WITHOUT_TIME_ZONE:
case INTERVAL_DAY_TIME:
TimestampData timestampData = TimestampData.fromEpochMillis(Long.valueOf(fieldValue));
record.setField(i, timestampData);
break;
case BINARY:
record.setField(i, Arrays.toString(fieldValue.getBytes(StandardCharsets.UTF_8)));
break;
+
Review Comment:
A little danger. While it doesn't matter
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [inlong] dockerzhang commented on pull request #7079: [INLONG-7076][Sort] Add multi table sink for MySQL
Posted by GitBox <gi...@apache.org>.
dockerzhang commented on PR #7079:
URL: https://github.com/apache/inlong/pull/7079#issuecomment-1367116693
@chyueyi do we need to update the document at the same time?
https://inlong.apache.org/docs/next/data_node/extract_node/mysql-cdc
if you want to change the document, you can create PR for https://github.com/apache/inlong-website.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org