Skip to content

Commit

Permalink
Merge pull request #3 from sap-contributions/EXPB-2253
Browse files Browse the repository at this point in the history
EXPB-2253 CALCITE-6401 JDBC adapter cannot push down joins with complex JOIN condition
  • Loading branch information
kramerul authored May 7, 2024
2 parents 0b3904e + dabc326 commit ae5672e
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions core/src/main/java/org/apache/calcite/adapter/jdbc/JdbcRules.java
Original file line number Diff line number Diff line change
Expand Up @@ -348,19 +348,19 @@ protected JdbcJoinRule(Config config) {
private static boolean canJoinOnCondition(RexNode node) {
final List<RexNode> operands;
switch (node.getKind()) {
case NOT:
case IS_NULL:
case IS_NOT_NULL:
case IS_FALSE:
case IS_NOT_FALSE:
case IS_TRUE:
case IS_NOT_TRUE:
case INPUT_REF:
case LITERAL:
// literal on a join condition would be TRUE or FALSE
return true;
case AND:
case OR:
operands = ((RexCall) node).getOperands();
for (RexNode operand : operands) {
if (!canJoinOnCondition(operand)) {
return false;
}
}
return true;

case EQUALS:
case IS_NOT_DISTINCT_FROM:
case NOT_EQUALS:
Expand All @@ -369,12 +369,12 @@ private static boolean canJoinOnCondition(RexNode node) {
case LESS_THAN:
case LESS_THAN_OR_EQUAL:
operands = ((RexCall) node).getOperands();
if ((operands.get(0) instanceof RexInputRef)
&& (operands.get(1) instanceof RexInputRef)) {
return true;
for (RexNode operand : operands) {
if (!canJoinOnCondition(operand)) {
return false;
}
}
// fall through

return true;
default:
return false;
}
Expand Down

0 comments on commit ae5672e

Please sign in to comment.