You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by GitBox <gi...@apache.org> on 2022/03/23 09:55:02 UTC

[GitHub] [incubator-seatunnel] BenJFan opened a new pull request #1544: [Feature][Connector] JDBC source support partition

BenJFan opened a new pull request #1544:
URL: https://github.com/apache/incubator-seatunnel/pull/1544


   <!--
   
   Thank you for contributing to SeaTunnel! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   ## Contribution Checklist
   
     - Make sure that the pull request corresponds to a [GITHUB issue](https://github.com/apache/incubator-seatunnel/issues).
   
     - Name the pull request in the form "[Feature] [component] Title of the pull request", where *Feature* can be replaced by `Hotfix`, `Bug`, etc.
   
     - Minor fixes should be named following this pattern: `[hotfix] [docs] Fix typo in README.md doc`.
   
   -->
   
   ## Purpose of this pull request
   Add partition series option to support jdbc parallelism
   This close #1543 
   <!-- Describe the purpose of this pull request. For example: This pull request adds checkstyle plugin.-->
   
   ## Check list
   
   * [ ] Code changed are covered with tests, or it does not need tests for reason:
   * [ ] If any new Jar binary package adding in you PR, please add License Notice according
     [New License Guide](https://github.com/apache/incubator-seatunnel/blob/dev/docs/en/developement/NewLicenseGuide.md)
   * [ ] If necessary, please update the documentation to describe the new feature. https://github.com/apache/incubator-seatunnel/tree/dev/docs
   


-- 
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@seatunnel.apache.org

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



[GitHub] [incubator-seatunnel] ruanwenjun commented on a change in pull request #1544: [Feature][Connector] JDBC source support partition

Posted by GitBox <gi...@apache.org>.
ruanwenjun commented on a change in pull request #1544:
URL: https://github.com/apache/incubator-seatunnel/pull/1544#discussion_r833391945



##########
File path: seatunnel-connectors/seatunnel-connectors-flink/seatunnel-connector-flink-jdbc/src/main/java/org/apache/seatunnel/flink/source/JdbcSource.java
##########
@@ -71,19 +80,17 @@
     private String password;
     private int fetchSize = DEFAULT_FETCH_SIZE;
     private Set<String> fields;
+    private int parallelism = 1;

Review comment:
       I find in the former code, the default value of parallelism in flink is -1. Why we change to 1?

##########
File path: seatunnel-connectors/seatunnel-connectors-flink/seatunnel-connector-flink-jdbc/src/main/java/org/apache/seatunnel/flink/source/JdbcSource.java
##########
@@ -116,41 +128,86 @@ public void prepare(FlinkEnvironment env) {
         if (config.hasPath(SOURCE_FETCH_SIZE)) {
             fetchSize = config.getInt(SOURCE_FETCH_SIZE);
         }
+        if (config.hasPath(PARALLELISM)) {
+            parallelism = config.getInt(PARALLELISM);
+        } else {
+            parallelism = env.getBatchEnvironment().getParallelism();
+        }
+        try {
+            Class.forName(driverName);
+            Connection connection = DriverManager.getConnection(dbUrl, username, password);

Review comment:
       The connection has not been closed here, it's better to close the connection in the finally or use try(Connection connection = xx)




-- 
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@seatunnel.apache.org

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



[GitHub] [incubator-seatunnel] CalvinKirs merged pull request #1544: [Feature][Connector] JDBC source support partition

Posted by GitBox <gi...@apache.org>.
CalvinKirs merged pull request #1544:
URL: https://github.com/apache/incubator-seatunnel/pull/1544


   


-- 
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@seatunnel.apache.org

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



[GitHub] [incubator-seatunnel] ruanwenjun commented on a change in pull request #1544: [Feature][Connector] JDBC source support partition

Posted by GitBox <gi...@apache.org>.
ruanwenjun commented on a change in pull request #1544:
URL: https://github.com/apache/incubator-seatunnel/pull/1544#discussion_r833391943



##########
File path: seatunnel-connectors/seatunnel-connectors-flink/seatunnel-connector-flink-jdbc/src/main/java/org/apache/seatunnel/flink/source/JdbcSource.java
##########
@@ -71,19 +80,17 @@
     private String password;
     private int fetchSize = DEFAULT_FETCH_SIZE;
     private Set<String> fields;
+    private int parallelism = 1;

Review comment:
       I find in the former code, the default value of parallelism in flink is -1. Why we change to 1?




-- 
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@seatunnel.apache.org

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



[GitHub] [incubator-seatunnel] ruanwenjun commented on a change in pull request #1544: [Feature][Connector] JDBC source support partition

Posted by GitBox <gi...@apache.org>.
ruanwenjun commented on a change in pull request #1544:
URL: https://github.com/apache/incubator-seatunnel/pull/1544#discussion_r834121038



##########
File path: docs/en/flink/configuration/source-plugins/Jdbc.md
##########
@@ -8,16 +8,19 @@ Read data through jdbc
 
 ## Options
 
-| name           | type   | required | default value |
-| -------------- | ------ | -------- | ------------- |
-| driver         | string | yes      | -             |
-| url            | string | yes      | -             |
-| username       | string | yes      | -             |
-| password       | string | no       | -             |
-| query          | string | yes      | -             |
-| fetch_size     | int    | no       | -             |
-| common-options | string | no       | -             |
-| parallelism    | int    | no       | -             |
+| name                  | type   | required | default value |
+|-----------------------| ------ | -------- | ------------- |
+| driver                | string | yes      | -             |
+| url                   | string | yes      | -             |
+| username              | string | yes      | -             |
+| password              | string | no       | -             |
+| query                 | string | yes      | -             |
+| fetch_size            | int    | no       | -             |
+| partition_column      | string | no       | -             |
+| partition_upper_bound | string | no       | -             |
+| partition_lower_bound | string | no       | -             |

Review comment:
       Change type to long




-- 
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@seatunnel.apache.org

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



[GitHub] [incubator-seatunnel] BenJFan commented on pull request #1544: [Feature][Connector] JDBC source support partition

Posted by GitBox <gi...@apache.org>.
BenJFan commented on pull request #1544:
URL: https://github.com/apache/incubator-seatunnel/pull/1544#issuecomment-1077277062


   > Just some little need to change, and we may also need to close the `JdbcInputFormat` in the close method.
   
   Thanks for advise. Already fix 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@seatunnel.apache.org

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



[GitHub] [incubator-seatunnel] ruanwenjun commented on a change in pull request #1544: [Feature][Connector] JDBC source support partition

Posted by GitBox <gi...@apache.org>.
ruanwenjun commented on a change in pull request #1544:
URL: https://github.com/apache/incubator-seatunnel/pull/1544#discussion_r834121470



##########
File path: docs/en/flink/configuration/source-plugins/Jdbc.md
##########
@@ -49,6 +52,18 @@ fetch size
 
 The parallelism of an individual operator, for JdbcSource.
 
+### partition_column [string]
+
+The column name for parallelism's partition, only support numeric type.
+
+### partition_upper_bound [int]
+
+The partition_column max value for scan, if not set SeaTunnel will query database get max value.
+
+### partition_lower_bound [int]

Review comment:
       Change type to long.




-- 
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@seatunnel.apache.org

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