Skip to content

Commit

Permalink
Push down join condition conjucnts to inner side based on inherited p…
Browse files Browse the repository at this point in the history
…redicate

Add equality conjuncts to inner side based on join condition and outer side symbol equalities from inherited predicate and outer side predicate
This is needed to handle queries like:

SELECT * FROM nation LEFT OUTER JOIN region ON nation.regionkey = region.regionkey and nation.name = region.name WHERE nation.name = 'blah'

Without that region.name = 'blah' was not pushed to inner side
  • Loading branch information
losipiuk authored and martint committed Jul 14, 2016
1 parent dfc6a8f commit d5cd68b
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,13 @@ private OuterJoinPushDownResult processLimitedOuterJoin(Expression inheritedPred
joinConjuncts.add(conjunct);
}
}

// Push outer and join equalities into the inner side. For example:
// SELECT * FROM nation LEFT OUTER JOIN region ON nation.regionkey = region.regionkey and nation.name = region.name WHERE nation.name = 'blah'

EqualityInference potentialNullSymbolInferenceWithoutInnerInferred = createEqualityInference(outerOnlyInheritedEqualities, outerEffectivePredicate, joinPredicate);
innerPushdownConjuncts.addAll(potentialNullSymbolInferenceWithoutInnerInferred.generateEqualitiesPartitionedBy(not(in(outerSymbols))).getScopeEqualities());

// TODO: we can further improve simplifying the equalities by considering other relationships from the outer side
EqualityInference.EqualityPartition joinEqualityPartition = createEqualityInference(joinPredicate).generateEqualitiesPartitionedBy(not(in(outerSymbols)));
innerPushdownConjuncts.addAll(joinEqualityPartition.getScopeEqualities());
Expand Down

0 comments on commit d5cd68b

Please sign in to comment.