use of io.prestosql.sql.planner.plan.EnforceSingleRowNode in project hetu-core by openlookeng.
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(idAllocator.getNextId(), subqueryPlan.getRoot()));
subqueryPlan = subqueryPlan.appendProjections(coercions, planSymbolAllocator, 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);
}
// The subquery's EnforceSingleRowNode always produces a row, so the join is effectively INNER
return appendLateralJoin(subPlan, subqueryPlan, scalarSubquery.getQuery(), correlationAllowed, LateralJoinNode.Type.INNER, TRUE_LITERAL);
}
use of io.prestosql.sql.planner.plan.EnforceSingleRowNode in project hetu-core by openlookeng.
the class TestCostCalculator method testEnforceSingleRow.
@Test
public void testEnforceSingleRow() {
TableScanNode ts1 = tableScan("ts1", "orderkey");
EnforceSingleRowNode singleRow = new EnforceSingleRowNode(new PlanNodeId("singleRow"), ts1);
Map<String, PlanNodeStatsEstimate> stats = ImmutableMap.of("ts1", statsEstimate(ts1, 4000), "singleRow", // 1 * Average Row Size
statsEstimate(ts1, 8));
Map<String, PlanCostEstimate> costs = ImmutableMap.of("ts1", cpuCost(1000));
Map<String, Type> types = ImmutableMap.of("orderkey", BIGINT);
assertCost(singleRow, costs, stats, types).cpu(// Only count the accumulated cost of source nodes
1000).memory(0).network(0);
assertCostEstimatedExchanges(singleRow, costs, stats, types).cpu(1000).memory(0).network(0);
}
Aggregations