You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "codeAntg (via GitHub)" <gi...@apache.org> on 2023/10/16 07:04:46 UTC
[PR] [feature] multiple tables to one [doris-flink-connector]
codeAntg opened a new pull request, #208:
URL: https://github.com/apache/doris-flink-connector/pull/208
**feature description :**
such as we have these tables that need to be synchronized.
mysql tables
a_0
a_1
b_0
b_1
c
doris tables
a
b
c
We can add two parameters to achieve this effect.
--including-tables="a_.\*|b_.\*|c"
--multi-to-one-origin="a_.\*|b_.\*"
--multi-to-one-target="a|b"
**Implementation principle :**
1.Create only one table
2.Multiple tables to one side output stream
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [feature] multiple tables to one [doris-flink-connector]
Posted by "JNSimba (via GitHub)" <gi...@apache.org>.
JNSimba commented on code in PR #208:
URL: https://github.com/apache/doris-flink-connector/pull/208#discussion_r1364794188
##########
flink-doris-connector/src/main/java/org/apache/doris/flink/tools/cdc/DatabaseSync.java:
##########
@@ -72,16 +76,19 @@ public abstract class DatabaseSync {
public void create(StreamExecutionEnvironment env, String database, Configuration config,
String tablePrefix, String tableSuffix, String includingTables,
- String excludingTables, boolean ignoreDefaultValue, Configuration sinkConfig,
+ String excludingTables,String multiToOneOrigin,String multiToOneTarget, boolean ignoreDefaultValue, Configuration sinkConfig,
Map<String, String> tableConfig, boolean createTableOnly, boolean useNewSchemaChange) {
this.env = env;
this.config = config;
this.database = database;
- this.converter = new TableNameConverter(tablePrefix, tableSuffix);
this.includingTables = includingTables;
this.excludingTables = excludingTables;
+ this.multiToOneOrigin = multiToOneOrigin;
+ this.multiToOneTarget = multiToOneTarget;
this.includingPattern = includingTables == null ? null : Pattern.compile(includingTables);
this.excludingPattern = excludingTables == null ? null : Pattern.compile(excludingTables);
+ this.multiToOneRulesPattern=multiToOneRulesParser(multiToOneOrigin,multiToOneTarget);
Review Comment:
Please manually format the code, such as spaces on both sides of =, thank you.
ps: In the future, code check-style will be added to automatically help verify these.
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [feature] multiple tables to one [doris-flink-connector]
Posted by "codeAntg (via GitHub)" <gi...@apache.org>.
codeAntg commented on code in PR #208:
URL: https://github.com/apache/doris-flink-connector/pull/208#discussion_r1365340150
##########
flink-doris-connector/src/main/java/org/apache/doris/flink/tools/cdc/DatabaseSync.java:
##########
@@ -72,16 +76,19 @@ public abstract class DatabaseSync {
public void create(StreamExecutionEnvironment env, String database, Configuration config,
String tablePrefix, String tableSuffix, String includingTables,
- String excludingTables, boolean ignoreDefaultValue, Configuration sinkConfig,
+ String excludingTables,String multiToOneOrigin,String multiToOneTarget, boolean ignoreDefaultValue, Configuration sinkConfig,
Map<String, String> tableConfig, boolean createTableOnly, boolean useNewSchemaChange) {
this.env = env;
this.config = config;
this.database = database;
- this.converter = new TableNameConverter(tablePrefix, tableSuffix);
this.includingTables = includingTables;
this.excludingTables = excludingTables;
+ this.multiToOneOrigin = multiToOneOrigin;
+ this.multiToOneTarget = multiToOneTarget;
this.includingPattern = includingTables == null ? null : Pattern.compile(includingTables);
this.excludingPattern = excludingTables == null ? null : Pattern.compile(excludingTables);
+ this.multiToOneRulesPattern=multiToOneRulesParser(multiToOneOrigin,multiToOneTarget);
Review Comment:
thanks,let me adjust 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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [feature] multiple tables to one [doris-flink-connector]
Posted by "JNSimba (via GitHub)" <gi...@apache.org>.
JNSimba commented on code in PR #208:
URL: https://github.com/apache/doris-flink-connector/pull/208#discussion_r1361565975
##########
flink-doris-connector/src/main/java/org/apache/doris/flink/tools/cdc/DatabaseSync.java:
##########
@@ -250,8 +288,42 @@ public static class TableNameConverter implements Serializable {
this.suffix = suffix == null ? "" : suffix;
}
+ TableNameConverter(String prefix, String suffix,Pattern multiToOnePattern,Map<Pattern, String> multiToOneRulesPattern) {
+ this.prefix = prefix == null ? "" : prefix;
+ this.suffix = suffix == null ? "" : suffix;
+ this.multiToOnePattern=multiToOnePattern;
+ this.multiToOneRulesPattern = multiToOneRulesPattern;
+ }
+
public String convert(String tableName) {
+ if(isMultiToOneTable(tableName)){
+ return getMultiToOneTargetByTableName(tableName);
+ }
Review Comment:
Is it possible to directly determine whether multiToOneRulesPattern is empty? If not, execute getMultiToOneTargetByTableName.
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [feature] multiple tables to one [doris-flink-connector]
Posted by "codeAntg (via GitHub)" <gi...@apache.org>.
codeAntg commented on code in PR #208:
URL: https://github.com/apache/doris-flink-connector/pull/208#discussion_r1365340877
##########
flink-doris-connector/src/main/java/org/apache/doris/flink/tools/cdc/DatabaseSync.java:
##########
@@ -235,11 +243,36 @@ protected boolean isSyncNeeded(String tableName) {
LOG.debug("table {} is synchronized? {}", tableName, sync);
return sync;
}
+ /**
+ * Filter table that many tables merge to one
+ */
+ protected HashMap<Pattern,String> multiToOneRulesParser(String multiToOneOrigin,String multiToOneTarget){
+ if(StringUtils.isEmpty(multiToOneOrigin) || StringUtils.isEmpty(multiToOneTarget)){
Review Comment:
thanks,let me adjust 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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [feature] multiple tables to one [doris-flink-connector]
Posted by "JNSimba (via GitHub)" <gi...@apache.org>.
JNSimba commented on code in PR #208:
URL: https://github.com/apache/doris-flink-connector/pull/208#discussion_r1364792582
##########
flink-doris-connector/src/main/java/org/apache/doris/flink/tools/cdc/DatabaseSync.java:
##########
@@ -235,11 +243,36 @@ protected boolean isSyncNeeded(String tableName) {
LOG.debug("table {} is synchronized? {}", tableName, sync);
return sync;
}
+ /**
+ * Filter table that many tables merge to one
+ */
+ protected HashMap<Pattern,String> multiToOneRulesParser(String multiToOneOrigin,String multiToOneTarget){
+ if(StringUtils.isEmpty(multiToOneOrigin) || StringUtils.isEmpty(multiToOneTarget)){
Review Comment:
Are you referring to the stringutils utility class? If yes, you can use flink’s own stringutils
##########
flink-doris-connector/src/main/java/org/apache/doris/flink/tools/cdc/DatabaseSync.java:
##########
@@ -235,11 +243,36 @@ protected boolean isSyncNeeded(String tableName) {
LOG.debug("table {} is synchronized? {}", tableName, sync);
return sync;
}
+ /**
+ * Filter table that many tables merge to one
+ */
+ protected HashMap<Pattern,String> multiToOneRulesParser(String multiToOneOrigin,String multiToOneTarget){
+ if(StringUtils.isEmpty(multiToOneOrigin) || StringUtils.isEmpty(multiToOneTarget)){
Review Comment:
Are you referring to the stringutils utility class? If yes, you can use flink’s own stringutils
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [feature] multiple tables to one [doris-flink-connector]
Posted by "JNSimba (via GitHub)" <gi...@apache.org>.
JNSimba commented on code in PR #208:
URL: https://github.com/apache/doris-flink-connector/pull/208#discussion_r1361546046
##########
flink-doris-connector/src/main/java/org/apache/doris/flink/tools/cdc/DatabaseSync.java:
##########
@@ -108,15 +116,23 @@ public void build() throws Exception {
List<String> dorisTables = new ArrayList<>();
for (SourceSchema schema : schemaList) {
syncTables.add(schema.getTableName());
- String dorisTable = converter.convert(schema.getTableName());
+ // 转换之前得判断是否是多表合一,多表合一不进行转换
+ String dorisTable="";
+ if(converter.isMultiToOneTable(schema.getTableName())){
+ dorisTable = converter.getMultiToOneTargetByTableName(schema.getTableName());
+ }else{
+ dorisTable = converter.convert(schema.getTableName());
+ }
Review Comment:
Can it be included in a method and handle the specific logic in the convert method?
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [feature] multiple tables to one [doris-flink-connector]
Posted by "JNSimba (via GitHub)" <gi...@apache.org>.
JNSimba commented on code in PR #208:
URL: https://github.com/apache/doris-flink-connector/pull/208#discussion_r1364794870
##########
flink-doris-connector/src/test/java/org/apache/doris/flink/tools/cdc/CdcPostgresSyncDatabaseCase.java:
##########
@@ -61,23 +61,27 @@ public static void main(String[] args) throws Exception{
Configuration config = Configuration.fromMap(sourceConfig);
Map<String,String> sinkConfig = new HashMap<>();
- sinkConfig.put("fenodes","10.20.30.1:8030");
+// sinkConfig.put("fenodes","10.20.30.1:8030");
+ sinkConfig.put("fenodes","172.20.80.2:8030");
Review Comment:
Try to hide the real IP
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [feature] multiple tables to one [doris-flink-connector]
Posted by "codeAntg (via GitHub)" <gi...@apache.org>.
codeAntg commented on code in PR #208:
URL: https://github.com/apache/doris-flink-connector/pull/208#discussion_r1365364776
##########
flink-doris-connector/src/test/java/org/apache/doris/flink/tools/cdc/CdcPostgresSyncDatabaseCase.java:
##########
@@ -61,23 +61,27 @@ public static void main(String[] args) throws Exception{
Configuration config = Configuration.fromMap(sourceConfig);
Map<String,String> sinkConfig = new HashMap<>();
- sinkConfig.put("fenodes","10.20.30.1:8030");
+// sinkConfig.put("fenodes","10.20.30.1:8030");
+ sinkConfig.put("fenodes","172.20.80.2:8030");
Review Comment:
thanks,I've deleted 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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [feature] multiple tables to one [doris-flink-connector]
Posted by "codeAntg (via GitHub)" <gi...@apache.org>.
codeAntg commented on code in PR #208:
URL: https://github.com/apache/doris-flink-connector/pull/208#discussion_r1363423891
##########
flink-doris-connector/src/main/java/org/apache/doris/flink/tools/cdc/DatabaseSync.java:
##########
@@ -235,11 +243,36 @@ protected boolean isSyncNeeded(String tableName) {
LOG.debug("table {} is synchronized? {}", tableName, sync);
return sync;
}
+ /**
+ * Filter table that many tables merge to one
+ */
+ protected HashMap<Pattern,String> multiToOneRulesParser(String multiToOneOrigin,String multiToOneTarget){
+ if(StringUtils.isEmpty(multiToOneOrigin) || StringUtils.isEmpty(multiToOneTarget)){
Review Comment:
Here I have a question, should i use this method to check it, because it will import a new package, I do not know whether it has some bad impact
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [feature] multiple tables to one [doris-flink-connector]
Posted by "JNSimba (via GitHub)" <gi...@apache.org>.
JNSimba commented on code in PR #208:
URL: https://github.com/apache/doris-flink-connector/pull/208#discussion_r1375590173
##########
flink-doris-connector/src/test/java/org/apache/doris/flink/tools/cdc/DatabaseSyncTest.java:
##########
@@ -0,0 +1,29 @@
+package org.apache.doris.flink.tools.cdc;
Review Comment:
please add license header, thanks
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [feature] multiple tables to one [doris-flink-connector]
Posted by "JNSimba (via GitHub)" <gi...@apache.org>.
JNSimba commented on code in PR #208:
URL: https://github.com/apache/doris-flink-connector/pull/208#discussion_r1361567370
##########
flink-doris-connector/src/main/java/org/apache/doris/flink/tools/cdc/DatabaseSync.java:
##########
@@ -235,12 +250,35 @@ protected boolean isSyncNeeded(String tableName) {
LOG.debug("table {} is synchronized? {}", tableName, sync);
return sync;
}
+ /**
+ * Filter table that many tables merge to one
+ */
+ protected HashMap<Pattern,String> multiToOneRulesParser(String multiToOneOrigin,String multiToOneTarget){
+ if(multiToOneOrigin==null || multiToOneTarget==null){
+ return null;
+ }
+ HashMap<Pattern,String> multiToOneRulesPattern= new HashMap<>();
+ String[] origins = multiToOneOrigin.split("\\|");
+ String[] targets = multiToOneTarget.split("\\|");
+ if(origins.length!=targets.length){
+ System.out.println("param error : multi to one params length are not equal,please check your params.");
+ System.exit(1);
+ }
+ for (int i = 0; i < origins.length; i++) {
+ multiToOneRulesPattern.put(Pattern.compile(origins[i]),targets[i]);
+ }
+ return multiToOneRulesPattern;
+ }
Review Comment:
This method recommends adding a unit test
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [feature] multiple tables to one [doris-flink-connector]
Posted by "codeAntg (via GitHub)" <gi...@apache.org>.
codeAntg commented on PR #208:
URL: https://github.com/apache/doris-flink-connector/pull/208#issuecomment-1767887233
Thank you for your advice, the code has been optimized, please check
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [feature] multiple tables to one [doris-flink-connector]
Posted by "codeAntg (via GitHub)" <gi...@apache.org>.
codeAntg commented on code in PR #208:
URL: https://github.com/apache/doris-flink-connector/pull/208#discussion_r1365338326
##########
flink-doris-connector/src/test/java/org/apache/doris/flink/tools/cdc/CdcPostgresSyncDatabaseCase.java:
##########
@@ -61,23 +61,27 @@ public static void main(String[] args) throws Exception{
Configuration config = Configuration.fromMap(sourceConfig);
Map<String,String> sinkConfig = new HashMap<>();
- sinkConfig.put("fenodes","10.20.30.1:8030");
+// sinkConfig.put("fenodes","10.20.30.1:8030");
+ sinkConfig.put("fenodes","172.20.80.2:8030");
Review Comment:
This is my local test environment, do I need to delete 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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [feature] multiple tables to one [doris-flink-connector]
Posted by "JNSimba (via GitHub)" <gi...@apache.org>.
JNSimba commented on code in PR #208:
URL: https://github.com/apache/doris-flink-connector/pull/208#discussion_r1361483077
##########
flink-doris-connector/src/main/java/org/apache/doris/flink/tools/cdc/DatabaseSync.java:
##########
@@ -108,15 +116,23 @@ public void build() throws Exception {
List<String> dorisTables = new ArrayList<>();
for (SourceSchema schema : schemaList) {
syncTables.add(schema.getTableName());
- String dorisTable = converter.convert(schema.getTableName());
+ // 转换之前得判断是否是多表合一,多表合一不进行转换
Review Comment:
English comments, thank you
##########
flink-doris-connector/src/main/java/org/apache/doris/flink/tools/cdc/DatabaseSync.java:
##########
@@ -108,15 +116,23 @@ public void build() throws Exception {
List<String> dorisTables = new ArrayList<>();
for (SourceSchema schema : schemaList) {
syncTables.add(schema.getTableName());
- String dorisTable = converter.convert(schema.getTableName());
+ // 转换之前得判断是否是多表合一,多表合一不进行转换
Review Comment:
Modified to English comments, thank you
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [feature] multiple tables to one [doris-flink-connector]
Posted by "JNSimba (via GitHub)" <gi...@apache.org>.
JNSimba commented on code in PR #208:
URL: https://github.com/apache/doris-flink-connector/pull/208#discussion_r1364792582
##########
flink-doris-connector/src/main/java/org/apache/doris/flink/tools/cdc/DatabaseSync.java:
##########
@@ -235,11 +243,36 @@ protected boolean isSyncNeeded(String tableName) {
LOG.debug("table {} is synchronized? {}", tableName, sync);
return sync;
}
+ /**
+ * Filter table that many tables merge to one
+ */
+ protected HashMap<Pattern,String> multiToOneRulesParser(String multiToOneOrigin,String multiToOneTarget){
+ if(StringUtils.isEmpty(multiToOneOrigin) || StringUtils.isEmpty(multiToOneTarget)){
Review Comment:
Are you referring to the stringutils utility class? If yes, you can use flink’s own org.apache.flink.util.StringUtils
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [feature] multiple tables to one [doris-flink-connector]
Posted by "JNSimba (via GitHub)" <gi...@apache.org>.
JNSimba merged PR #208:
URL: https://github.com/apache/doris-flink-connector/pull/208
--
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@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org