You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/07/19 10:12:54 UTC

[GitHub] [flink] leonardBang commented on a diff in pull request #18469: [FLINK-25485][connector/jdbc] Append default JDBC URL option of batch writing in MySQL.

leonardBang commented on code in PR #18469:
URL: https://github.com/apache/flink/pull/18469#discussion_r924312328


##########
flink-connectors/flink-connector-jdbc/src/main/java/org/apache/flink/connector/jdbc/dialect/mysql/MySqlDialect.java:
##########
@@ -126,4 +126,14 @@ public Set<LogicalTypeRoot> supportedTypes() {
                 LogicalTypeRoot.TIME_WITHOUT_TIME_ZONE,
                 LogicalTypeRoot.TIMESTAMP_WITHOUT_TIME_ZONE);
     }
+
+    @Override
+    public String appendUrlSuffix(String url) {
+        String suffix = "rewriteBatchedStatements=true";

Review Comment:
   This can be a constant with a meaningful note.



##########
flink-connectors/flink-connector-jdbc/src/main/java/org/apache/flink/connector/jdbc/dialect/mysql/MySqlDialect.java:
##########
@@ -126,4 +126,14 @@ public Set<LogicalTypeRoot> supportedTypes() {
                 LogicalTypeRoot.TIME_WITHOUT_TIME_ZONE,
                 LogicalTypeRoot.TIMESTAMP_WITHOUT_TIME_ZONE);
     }
+
+    @Override
+    public String appendUrlSuffix(String url) {
+        String suffix = "rewriteBatchedStatements=true";
+        if (url.contains("?")) {
+            return url + "&" + suffix;

Review Comment:
   We should user's url `rewriteBatchedStatements=false` if the user configured url contains `rewriteBatchedStatements=false` instead of use the default property.



##########
flink-connectors/flink-connector-jdbc/src/main/java/org/apache/flink/connector/jdbc/dialect/JdbcDialect.java:
##########
@@ -142,4 +142,14 @@ Optional<String> getUpsertStatement(
      */
     String getSelectFromStatement(
             String tableName, String[] selectFields, String[] conditionFields);
+
+    /**
+     * Some database need require additional JDBC options,such as MySQL require
+     * rewriteBatchedStatements=true to enable batch writing. Inspired by the Alibaba DataX.
+     *
+     * @return A JDBC url.
+     */
+    default String appendUrlSuffix(String url) {

Review Comment:
   how about `appendDefaultUrlProperties`?



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org