Do not create new join node when equi criteria and filter are same
@@ -410,10 +410,7 @@ public class PredicatePushDown
PlanNode rightSource = context.rewrite(node.getRight(), rightPredicate);
PlanNode output = node;
- if (leftSource != node.getLeft() ||
- rightSource != node.getRight() ||
- !expressionEquivalence.areExpressionsEquivalent(session, newJoinPredicate, joinPredicate, types) ||
- node.getCriteria().isEmpty()) {
+
// Create identity projections for all existing symbols
Assignments.Builder leftProjections = Assignments.builder();
leftProjections.putAll(node.getLeft()
@@ -467,6 +464,14 @@ public class PredicatePushDown
newJoinFilter = Optional.empty();
}
+ boolean filtersEquivalent =
+ newJoinFilter.isPresent() == node.getFilter().isPresent() &&
+ (!newJoinFilter.isPresent() || expressionEquivalence.areExpressionsEquivalent(session, newJoinFilter.get(), node.getFilter().get(), types));
+
+ if (leftSource != node.getLeft() ||
+ rightSource != node.getRight() ||
+ !filtersEquivalent ||
+ !ImmutableSet.copyOf(equiJoinClauses).equals(ImmutableSet.copyOf(node.getCriteria()))) {
leftSource = new ProjectNode(idAllocator.getNextId(), leftSource, leftProjections.build());
rightSource = new ProjectNode(idAllocator.getNextId(), rightSource, rightProjections.build());
