use of com.facebook.presto.sql.planner.plan.ApplyNode in project urban-eureka by errir503.
the class CheckSubqueryNodesAreRewritten method optimize.
@Override
public PlanNode optimize(PlanNode plan, Session session, TypeProvider types, PlanVariableAllocator variableAllocator, PlanNodeIdAllocator idAllocator, WarningCollector warningCollector) {
searchFrom(plan).where(ApplyNode.class::isInstance).findFirst().ifPresent(node -> {
ApplyNode applyNode = (ApplyNode) node;
error(applyNode.getCorrelation(), applyNode.getOriginSubqueryError());
});
searchFrom(plan).where(LateralJoinNode.class::isInstance).findFirst().ifPresent(node -> {
LateralJoinNode lateralJoinNode = (LateralJoinNode) node;
error(lateralJoinNode.getCorrelation(), lateralJoinNode.getOriginSubqueryError());
});
return plan;
}
use of com.facebook.presto.sql.planner.plan.ApplyNode in project urban-eureka by errir503.
the class SubqueryPlanner method appendApplyNode.
private PlanBuilder appendApplyNode(PlanBuilder subPlan, Node subquery, PlanNode subqueryNode, Assignments subqueryAssignments, boolean correlationAllowed) {
Map<Expression, Expression> correlation = extractCorrelation(subPlan, subqueryNode);
if (!correlationAllowed && !correlation.isEmpty()) {
throw notSupportedException(subquery, "Correlated subquery in given context");
}
subPlan = subPlan.appendProjections(correlation.keySet(), variableAllocator, idAllocator);
subqueryNode = replaceExpressionsWithSymbols(subqueryNode, correlation);
TranslationMap translations = subPlan.copyTranslations();
PlanNode root = subPlan.getRoot();
verifySubquerySupported(subqueryAssignments);
return new PlanBuilder(translations, new ApplyNode(subqueryNode.getSourceLocation(), idAllocator.getNextId(), root, subqueryNode, subqueryAssignments, ImmutableList.copyOf(VariablesExtractor.extractUnique(correlation.values(), variableAllocator.getTypes())), subQueryNotSupportedError(subquery, "Given correlated subquery")));
}
use of com.facebook.presto.sql.planner.plan.ApplyNode in project urban-eureka by errir503.
the class TestVerifyNoOriginalExpression method testValidateForApplyFailed.
@Test(expectedExceptions = IllegalArgumentException.class)
public void testValidateForApplyFailed() {
ImmutableMap<VariableReferenceExpression, RowExpression> map = ImmutableMap.of(VARIABLE_REFERENCE_EXPRESSION, castToRowExpression(new SymbolReference("count")));
Assignments assignments = new Assignments(map);
ImmutableList<VariableReferenceExpression> variableReferenceExpressions = ImmutableList.of(VARIABLE_REFERENCE_EXPRESSION);
ApplyNode applyNode = builder.apply(assignments, variableReferenceExpressions, valuesNode, valuesNode);
testValidation(applyNode);
}
use of com.facebook.presto.sql.planner.plan.ApplyNode in project presto by prestodb.
the class CorrelationMatcher method detailMatches.
@Override
public MatchResult detailMatches(PlanNode node, Session session, Metadata metadata, SymbolAliases symbolAliases) {
checkState(shapeMatches(node), "Plan testing framework error: shapeMatches returned false in detailMatches in %s", this.getClass().getName());
ApplyNode applyNode = (ApplyNode) node;
if (correlation.size() != applyNode.getCorrelation().size()) {
return NO_MATCH;
}
int i = 0;
for (String alias : correlation) {
if (!symbolAliases.get(alias).equals(applyNode.getCorrelation().get(i++).toSymbolReference())) {
return NO_MATCH;
}
}
return match();
}
Aggregations