use of io.trino.sql.planner.optimizations.PlanNodeDecorrelator.DecorrelatedNode in project trino by trinodb.
the class TransformCorrelatedJoinToJoin method apply.
@Override
public Result apply(CorrelatedJoinNode correlatedJoinNode, Captures captures, Context context) {
checkArgument(correlatedJoinNode.getType() == INNER || correlatedJoinNode.getType() == LEFT, "correlation in %s JOIN", correlatedJoinNode.getType().name());
PlanNode subquery = correlatedJoinNode.getSubquery();
PlanNodeDecorrelator planNodeDecorrelator = new PlanNodeDecorrelator(plannerContext, context.getSymbolAllocator(), context.getLookup());
Optional<DecorrelatedNode> decorrelatedNodeOptional = planNodeDecorrelator.decorrelateFilters(subquery, correlatedJoinNode.getCorrelation());
if (decorrelatedNodeOptional.isEmpty()) {
return Result.empty();
}
DecorrelatedNode decorrelatedSubquery = decorrelatedNodeOptional.get();
Expression filter = combineConjuncts(plannerContext.getMetadata(), decorrelatedSubquery.getCorrelatedPredicates().orElse(TRUE_LITERAL), correlatedJoinNode.getFilter());
return Result.ofPlanNode(new JoinNode(correlatedJoinNode.getId(), correlatedJoinNode.getType().toJoinNodeType(), correlatedJoinNode.getInput(), decorrelatedSubquery.getNode(), ImmutableList.of(), correlatedJoinNode.getInput().getOutputSymbols(), correlatedJoinNode.getSubquery().getOutputSymbols(), false, filter.equals(TRUE_LITERAL) ? Optional.empty() : Optional.of(filter), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), ImmutableMap.of(), Optional.empty()));
}
Aggregations