davidradl commented on code in PR #79: URL: https://github.com/apache/flink-connector-jdbc/pull/79#discussion_r1443986879
########## flink-connector-jdbc/src/main/java/org/apache/flink/connector/jdbc/table/ParameterizedPredicate.java: ########## @@ -52,8 +69,26 @@ public void setPredicate(String predicate) { } public ParameterizedPredicate combine(String operator, ParameterizedPredicate that) { + int paramIndex = String.format("(%s %s ", this.predicate, operator).length(); + if (!that.indexesOfPredicatePlaceHolders.isEmpty()) { + paramIndex = paramIndex + that.indexesOfPredicatePlaceHolders.get(0); + } + this.predicate = String.format("(%s %s %s)", this.predicate, operator, that.predicate); this.parameters = ArrayUtils.addAll(this.parameters, that.parameters); + + for (int i = 0; i < this.indexesOfPredicatePlaceHolders.size(); i++) { + // increment all the existing indexes to account for the new additional first begin + // bracket + this.indexesOfPredicatePlaceHolders.set( + i, this.indexesOfPredicatePlaceHolders.get(i) + 1); + } + if (that.predicate.equals( + JdbcFilterPushdownPreparedStatementVisitor.PUSHDOWN_PREDICATE_PLACEHOLDER) + || (!that.indexesOfPredicatePlaceHolders.isEmpty())) { + // add index if that is a placeholder or has a placeholder. + this.indexesOfPredicatePlaceHolders.add(paramIndex); + } Review Comment: @snuyanzin I have amended the code locally to work with `?` on the left. Also queries of the type `SELECT * FROM a left join d FOR SYSTEM_TIME AS OF a.proctime on ((d.age = 50 AND d.type = 0) OR (d.type = 1 AND d.age =40)) and a.ip = d.ip;` are working for me locally . I intend to put up the latest fix once I have done more testing. But if you think the index design has a more fundamental flaw, then we will need to rethink. I appreciate you drawing attention to the queries that are not working. The latest fix stashes the indexes in the visitor if the indexes are correct then we can replace parameters only where we know we should. -- 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-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org