/** * Implicit coercions are added when mapping an expression to symbol in {@link TranslationMap}. Coercions * for expression are obtained from {@link Analysis} by identity comparison. Create a copy of subquery * in order to get a subquery expression that does not have any coercion assigned to it {@link Analysis}. */ private SubqueryExpression uncoercedSubquery(SubqueryExpression subquery) { return new SubqueryExpression(subquery.getQuery()); }
@Override protected R visitSubqueryExpression(SubqueryExpression node, C context) { return process(node.getQuery(), context); }
/** * Implicit coercions are added when mapping an expression to symbol in {@link TranslationMap}. Coercions * for expression are obtained from {@link Analysis} by identity comparison. Create a copy of subquery * in order to get a subquery expression that does not have any coercion assigned to it {@link Analysis}. */ private SubqueryExpression uncoercedSubquery(SubqueryExpression subquery) { return new SubqueryExpression(subquery.getQuery()); }
@Override protected String visitSubqueryExpression(SubqueryExpression node, Void context) { return "(" + formatSql(node.getQuery(), parameters) + ")"; }
@Override protected String visitSubqueryExpression(SubqueryExpression node, Void context) { return "(" + formatSql(node.getQuery(), parameters) + ")"; }
@Override protected R visitSubqueryExpression(SubqueryExpression node, C context) { return process(node.getQuery(), context); }
.withParent(context.getContext().getScope()) .build(); Scope queryScope = analyzer.analyze(node.getQuery(), subqueryScope);
.withParent(context.getContext().getScope()) .build(); Scope queryScope = analyzer.analyze(node.getQuery(), subqueryScope);
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(idAllocator.getNextId(), subqueryPlan.getRoot())); subqueryPlan = subqueryPlan.appendProjections(coercions, symbolAllocator, idAllocator); Symbol uncoercedScalarSubquerySymbol = subqueryPlan.translate(uncoercedScalarSubquery); subPlan.getTranslations().put(uncoercedScalarSubquery, uncoercedScalarSubquerySymbol); for (Expression coercion : coercions) { Symbol coercionSymbol = subqueryPlan.translate(coercion); subPlan.getTranslations().put(coercion, coercionSymbol); } return appendLateralJoin(subPlan, subqueryPlan, scalarSubquery.getQuery(), correlationAllowed, LateralJoinNode.Type.LEFT); }
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(idAllocator.getNextId(), subqueryPlan.getRoot())); subqueryPlan = subqueryPlan.appendProjections(coercions, symbolAllocator, idAllocator); Symbol uncoercedScalarSubquerySymbol = subqueryPlan.translate(uncoercedScalarSubquery); subPlan.getTranslations().put(uncoercedScalarSubquery, uncoercedScalarSubquerySymbol); for (Expression coercion : coercions) { Symbol coercionSymbol = subqueryPlan.translate(coercion); subPlan.getTranslations().put(coercion, coercionSymbol); } return appendLateralJoin(subPlan, subqueryPlan, scalarSubquery.getQuery(), correlationAllowed, LateralJoinNode.Type.LEFT); }