use of io.trino.sql.planner.plan.ApplyNode in project trino by trinodb.
the class PruneApplyCorrelation method apply.
@Override
public Result apply(ApplyNode applyNode, Captures captures, Context context) {
Set<Symbol> subquerySymbols = extractUnique(applyNode.getSubquery(), context.getLookup());
List<Symbol> newCorrelation = applyNode.getCorrelation().stream().filter(subquerySymbols::contains).collect(toImmutableList());
if (newCorrelation.size() < applyNode.getCorrelation().size()) {
return Result.ofPlanNode(new ApplyNode(applyNode.getId(), applyNode.getInput(), applyNode.getSubquery(), applyNode.getSubqueryAssignments(), newCorrelation, applyNode.getOriginSubquery()));
}
return Result.empty();
}
use of io.trino.sql.planner.plan.ApplyNode in project trino by trinodb.
the class CheckSubqueryNodesAreRewritten method optimize.
@Override
public PlanNode optimize(PlanNode plan, Session session, TypeProvider types, SymbolAllocator symbolAllocator, PlanNodeIdAllocator idAllocator, WarningCollector warningCollector) {
searchFrom(plan).where(ApplyNode.class::isInstance).findFirst().ifPresent(node -> {
ApplyNode applyNode = (ApplyNode) node;
throw error(applyNode.getCorrelation(), applyNode.getOriginSubquery());
});
searchFrom(plan).where(CorrelatedJoinNode.class::isInstance).findFirst().ifPresent(node -> {
CorrelatedJoinNode correlatedJoinNode = (CorrelatedJoinNode) node;
throw error(correlatedJoinNode.getCorrelation(), correlatedJoinNode.getOriginSubquery());
});
return plan;
}
Aggregations