Skip to content

Commit

Permalink
Remove unnecessary simplification step
Browse files Browse the repository at this point in the history
This step is not needed anymore as
corresponding tests do not fail.
  • Loading branch information
sopel39 committed Dec 22, 2023
1 parent b2e98e9 commit fb190ef
Showing 1 changed file with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1008,16 +1008,10 @@ private InnerJoinPushDownResult processInnerJoin(
ImmutableSet<Symbol> leftScope = ImmutableSet.copyOf(leftSymbols);
ImmutableSet<Symbol> rightScope = ImmutableSet.copyOf(rightSymbols);

// Attempt to simplify the effective left/right predicates with the predicate we're pushing down
// This, effectively, inlines any constants derived from such predicate
EqualityInference predicateInference = new EqualityInference(metadata, inheritedPredicate);
Expression simplifiedLeftEffectivePredicate = predicateInference.rewrite(leftEffectivePredicate, leftScope);
Expression simplifiedRightEffectivePredicate = predicateInference.rewrite(rightEffectivePredicate, rightScope);

// Generate equality inferences
EqualityInference allInference = new EqualityInference(metadata, inheritedPredicate, leftEffectivePredicate, rightEffectivePredicate, joinPredicate, simplifiedLeftEffectivePredicate, simplifiedRightEffectivePredicate);
EqualityInference allInferenceWithoutLeftInferred = new EqualityInference(metadata, inheritedPredicate, rightEffectivePredicate, joinPredicate, simplifiedRightEffectivePredicate);
EqualityInference allInferenceWithoutRightInferred = new EqualityInference(metadata, inheritedPredicate, leftEffectivePredicate, joinPredicate, simplifiedLeftEffectivePredicate);
EqualityInference allInference = new EqualityInference(metadata, inheritedPredicate, leftEffectivePredicate, rightEffectivePredicate, joinPredicate);
EqualityInference allInferenceWithoutLeftInferred = new EqualityInference(metadata, inheritedPredicate, rightEffectivePredicate, joinPredicate);
EqualityInference allInferenceWithoutRightInferred = new EqualityInference(metadata, inheritedPredicate, leftEffectivePredicate, joinPredicate);

// Add equalities from the inference back in
leftPushDownConjuncts.addAll(allInferenceWithoutLeftInferred.generateEqualitiesPartitionedBy(leftScope).getScopeEqualities());
Expand All @@ -1043,13 +1037,13 @@ private InnerJoinPushDownResult processInnerJoin(
});

// See if we can push the right effective predicate to the left side
EqualityInference.nonInferrableConjuncts(metadata, simplifiedRightEffectivePredicate)
EqualityInference.nonInferrableConjuncts(metadata, rightEffectivePredicate)
.map(conjunct -> allInference.rewrite(conjunct, leftScope))
.filter(Objects::nonNull)
.forEach(leftPushDownConjuncts::add);

// See if we can push the left effective predicate to the right side
EqualityInference.nonInferrableConjuncts(metadata, simplifiedLeftEffectivePredicate)
EqualityInference.nonInferrableConjuncts(metadata, leftEffectivePredicate)
.map(conjunct -> allInference.rewrite(conjunct, rightScope))
.filter(Objects::nonNull)
.forEach(rightPushDownConjuncts::add);
Expand Down

0 comments on commit fb190ef

Please sign in to comment.