[branch-2.1][fix](jdbc scan) Remove the conjuncts.remove call in JdbcScan (#39407)

pick (#39180)

In #37565, due to the change in the calling order of finalize, the final
generated Plan will be missing the PREDICATES that have been pushed down
in Jdbc. Although this behavior is correct, before perfectly handling
the push down of various PREDICATES, we need to keep all conjuncts to
ensure that we can still filter data normally when the data returned by
Jdbc is a superset.
This commit is contained in:
zy-kkk
2024-08-16 19:01:40 +08:00
committed by GitHub
parent f203ee8224
commit 2948b5ea2b
6 changed files with 147 additions and 131 deletions

View File

@ -61,6 +61,7 @@ public class JdbcScanNode extends ExternalScanNode {
private final List<String> columns = new ArrayList<String>();
private final List<String> filters = new ArrayList<String>();
private final List<Expr> pushedDownConjuncts = new ArrayList<>();
private String tableName;
private TOdbcTableType jdbcType;
private String graphQueryString = "";
@ -128,7 +129,7 @@ public class JdbcScanNode extends ExternalScanNode {
for (Expr individualConjunct : pushDownConjuncts) {
String filter = conjunctExprToString(jdbcType, individualConjunct, tbl);
filters.add(filter);
conjuncts.remove(individualConjunct);
pushedDownConjuncts.add(individualConjunct);
}
}
@ -165,7 +166,7 @@ public class JdbcScanNode extends ExternalScanNode {
}
private boolean shouldPushDownLimit() {
return limit != -1 && conjuncts.isEmpty();
return limit != -1 && conjuncts.size() == pushedDownConjuncts.size();
}
private String getJdbcQueryStr() {

View File

@ -60,6 +60,7 @@ public class OdbcScanNode extends ExternalScanNode {
private final List<String> columns = new ArrayList<String>();
private final List<String> filters = new ArrayList<String>();
private final List<Expr> pushedDownConjuncts = new ArrayList<>();
private String tblName;
private String connectString;
private TOdbcTableType odbcType;
@ -138,7 +139,7 @@ public class OdbcScanNode extends ExternalScanNode {
// only all conjuncts be pushed down as filter, we can
// push down limit operation to ODBC table
private boolean shouldPushDownLimit() {
return limit != -1 && conjuncts.isEmpty();
return limit != -1 && conjuncts.size() == pushedDownConjuncts.size();
}
private String getOdbcQueryStr() {
@ -208,7 +209,7 @@ public class OdbcScanNode extends ExternalScanNode {
if (shouldPushDownConjunct(odbcType, p)) {
String filter = JdbcScanNode.conjunctExprToString(odbcType, p, tbl);
filters.add(filter);
conjuncts.remove(p);
pushedDownConjuncts.add(p);
}
}
}