qingwei91 commented on code in PR #79:
URL:
https://github.com/apache/flink-connector-jdbc/pull/79#discussion_r1394734975
##########
flink-connector-jdbc/src/main/java/org/apache/flink/connector/jdbc/table/JdbcDynamicTableSource.java:
##########
@@ -96,21 +96,35 @@ public JdbcDynamicTableSource(
public LookupRuntimeProvider getLookupRuntimeProvider(LookupContext
context) {
// JDBC only support non-nested look up keys
String[] keyNames = new String[context.getKeys().length];
- for (int i = 0; i < keyNames.length; i++) {
+
+ for (int i = 0; i < context.getKeys().length; i++) {
int[] innerKeyArr = context.getKeys()[i];
Preconditions.checkArgument(
innerKeyArr.length == 1, "JDBC only support non-nested
look up keys");
keyNames[i] =
DataType.getFieldNames(physicalRowDataType).get(innerKeyArr[0]);
}
+
final RowType rowType = (RowType) physicalRowDataType.getLogicalType();
+
+ String[] conditions = null;
+ if (this.resolvedPredicates != null) {
+ conditions = new String[this.resolvedPredicates.size()];
+ for (int i = 0; i < this.resolvedPredicates.size(); i++) {
+ String resolvedPredicate = this.resolvedPredicates.get(i);
+ String param = this.pushdownParams[i].toString();
+ conditions[i] = (resolvedPredicate.replace("?", param));
Review Comment:
If you want to do it as Benchao Li suggested, ie. to use prepared statement.
You can take a look at this class, its used in the ScanSource
https://github.com/apache/flink-connector-jdbc/blob/main/flink-connector-jdbc/src/main/java/org/apache/flink/connector/jdbc/table/JdbcRowDataInputFormat.java#L159
Essentially it uses PrepareStatement to produce the final query string, from
what I can tell `JdbcRowDataLookupFunction` already uses PreparedStatement, so
we might be able to leverage that
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]