use of com.facebook.presto.sql.planner.plan.EnforceSingleRowNode in project presto by prestodb.
the class SubqueryPlanner method appendScalarSubqueryApplyNode.
private PlanBuilder appendScalarSubqueryApplyNode(PlanBuilder subPlan, SubqueryExpression scalarSubquery, boolean correlationAllowed) {
if (subPlan.canTranslate(scalarSubquery)) {
// given subquery is already appended
return subPlan;
}
List<Expression> coercions = coercionsFor(scalarSubquery);
SubqueryExpression uncoercedScalarSubquery = uncoercedSubquery(scalarSubquery);
PlanBuilder subqueryPlan = createPlanBuilder(uncoercedScalarSubquery);
subqueryPlan = subqueryPlan.withNewRoot(new EnforceSingleRowNode(subPlan.getRoot().getSourceLocation(), idAllocator.getNextId(), subqueryPlan.getRoot()));
subqueryPlan = subqueryPlan.appendProjections(coercions, variableAllocator, idAllocator);
VariableReferenceExpression uncoercedScalarSubqueryVariable = subqueryPlan.translate(uncoercedScalarSubquery);
subPlan.getTranslations().put(uncoercedScalarSubquery, uncoercedScalarSubqueryVariable);
for (Expression coercion : coercions) {
VariableReferenceExpression coercionVariable = subqueryPlan.translate(coercion);
subPlan.getTranslations().put(coercion, coercionVariable);
}
return appendLateralJoin(subPlan, subqueryPlan, scalarSubquery.getQuery(), correlationAllowed, LateralJoinNode.Type.LEFT);
}
Aggregations