use of io.prestosql.spi.plan.ProjectNode in project hetu-core by openlookeng.
the class TestPruneFilterColumns method buildProjectedFilter.
private ProjectNode buildProjectedFilter(PlanBuilder planBuilder, Predicate<Symbol> projectionFilter) {
Symbol a = planBuilder.symbol("a");
Symbol b = planBuilder.symbol("b");
return planBuilder.project(Assignments.copyOf(Stream.of(a, b).filter(projectionFilter).collect(Collectors.toMap(v -> v, v -> planBuilder.variable(v.getName())))), planBuilder.filter(PlanBuilder.expression("b > 5"), planBuilder.values(a, b)));
}
use of io.prestosql.spi.plan.ProjectNode in project hetu-core by openlookeng.
the class TestTypeValidator method testValidTypeOnlyCoercion.
@Test
public void testValidTypeOnlyCoercion() {
Expression expression = new Cast(toSymbolReference(columnB), StandardTypes.BIGINT);
Assignments assignments = Assignments.builder().put(planSymbolAllocator.newSymbol(expression, BIGINT), castToRowExpression(expression)).put(planSymbolAllocator.newSymbol(toSymbolReference(columnE), VARCHAR), // implicit coercion from varchar(3) to varchar
castToRowExpression(toSymbolReference(columnE))).build();
PlanNode node = new ProjectNode(newId(), baseTableScan, assignments);
assertTypesValid(node);
}
use of io.prestosql.spi.plan.ProjectNode in project hetu-core by openlookeng.
the class TestTypeValidator method testValidProject.
@Test
public void testValidProject() {
Expression expression1 = new Cast(toSymbolReference(columnB), StandardTypes.BIGINT);
Expression expression2 = new Cast(toSymbolReference(columnC), StandardTypes.BIGINT);
Assignments assignments = Assignments.builder().put(planSymbolAllocator.newSymbol(expression1, BIGINT), castToRowExpression(expression1)).put(planSymbolAllocator.newSymbol(expression2, BIGINT), castToRowExpression(expression2)).build();
PlanNode node = new ProjectNode(newId(), baseTableScan, assignments);
assertTypesValid(node);
}
use of io.prestosql.spi.plan.ProjectNode in project hetu-core by openlookeng.
the class SimpleFilterProjectSemiJoinStatsRule method doCalculate.
@Override
protected Optional<PlanNodeStatsEstimate> doCalculate(FilterNode node, StatsProvider sourceStats, Lookup lookup, Session session, TypeProvider types) {
PlanNode nodeSource = lookup.resolve(node.getSource());
SemiJoinNode semiJoinNode;
if (nodeSource instanceof ProjectNode) {
ProjectNode projectNode = (ProjectNode) nodeSource;
if (!isIdentity(projectNode)) {
return Optional.empty();
}
PlanNode projectNodeSource = lookup.resolve(projectNode.getSource());
if (!(projectNodeSource instanceof SemiJoinNode)) {
return Optional.empty();
}
semiJoinNode = (SemiJoinNode) projectNodeSource;
} else if (nodeSource instanceof SemiJoinNode) {
semiJoinNode = (SemiJoinNode) nodeSource;
} else {
return Optional.empty();
}
return calculate(node, semiJoinNode, sourceStats, session, types);
}
Aggregations