Skip to content

Commit 3cd1b54

Browse files
committed
Enhance index join lookup variable extraction logic
1 parent 576d422 commit 3cd1b54

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

presto-main-base/src/main/java/com/facebook/presto/sql/planner/optimizations/IndexJoinOptimizer.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -347,11 +347,17 @@ public PlanNode visitJoin(JoinNode node, RewriteContext<Void> context)
347347

348348
// Extract non-equal join keys.
349349
if (node.getFilter().isPresent()) {
350-
LookupVariableExtractor.Context commonExtractorContext = new LookupVariableExtractor.Context(new HashSet<>(), functionResolution);
351-
LookupVariableExtractor.extractFromFilter(node.getFilter().get(), commonExtractorContext);
352-
if (commonExtractorContext.isEligible()) {
353-
leftLookupVariables.addAll(commonExtractorContext.getLookupVariables());
354-
rightLookupVariables.addAll(commonExtractorContext.getLookupVariables());
350+
LookupVariableExtractor.Context filterExtractorContext = new LookupVariableExtractor.Context(new HashSet<>(), functionResolution);
351+
LookupVariableExtractor.extractFromFilter(node.getFilter().get(), filterExtractorContext);
352+
if (filterExtractorContext.isEligible()) {
353+
for (VariableReferenceExpression variableExpression : filterExtractorContext.getLookupVariables()) {
354+
if (node.getLeft().getOutputVariables().contains(variableExpression)) {
355+
leftLookupVariables.add(variableExpression);
356+
}
357+
if (node.getRight().getOutputVariables().contains(variableExpression)) {
358+
rightLookupVariables.add(variableExpression);
359+
}
360+
}
355361
}
356362
else {
357363
return node;

0 commit comments

Comments
 (0)