wuchong commented on a change in pull request #9029: [FLINK-13118][jdbc]
Introduce JDBC table factory and bridge JDBC table source with streaming table
source
URL: https://github.com/apache/flink/pull/9029#discussion_r302523552
##########
File path:
flink-connectors/flink-jdbc/src/main/java/org/apache/flink/api/java/io/jdbc/JDBCTableSource.java
##########
@@ -74,12 +122,74 @@ public static Builder builder() {
return new Builder();
}
+ private JDBCInputFormat getInputFormat() {
+ JDBCInputFormat.JDBCInputFormatBuilder builder =
JDBCInputFormat.buildJDBCInputFormat()
+ .setDrivername(options.getDriverName())
+ .setDBUrl(options.getDbURL())
+ .setUsername(options.getUsername())
+ .setPassword(options.getPassword())
+ .setRowTypeInfo(new
RowTypeInfo(returnType.getFieldTypes(), returnType.getFieldNames()));
+
+ if (scanOptions.getFetchSize() != 0) {
+ builder.setFetchSize(scanOptions.getFetchSize());
+ }
+
+ final JDBCDialect dialect = options.getDialect();
+ String query = dialect.getSelectFromStatement(
+ options.getTableName(), returnType.getFieldNames(), new
String[0]);
+ if (scanOptions.getPartitionColumnName() != null) {
+ long lowerBound = scanOptions.getPartitionLowerBound();
+ long upperBound = scanOptions.getPartitionUpperBound();
+ int numPartitions = scanOptions.getNumPartitions();
+ builder.setParametersProvider(
+ new
NumericBetweenParametersProvider(lowerBound,
upperBound).ofBatchNum(numPartitions));
+ query += " WHERE " +
+
dialect.quoteIdentifier(scanOptions.getPartitionColumnName()) +
+ " BETWEEN ? AND ?";
+ }
+ builder.setQuery(query);
+
+ return builder.finish();
+ }
+
+ private void calculateReturnType() {
Review comment:
Move the content of this method to constructor and we can mark `returnType`
final.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services