use of io.prestosql.spi.plan.ProjectNode in project hetu-core by openlookeng.
the class TestPruneAggregationColumns method buildProjectedAggregation.
private ProjectNode buildProjectedAggregation(PlanBuilder planBuilder, Predicate<Symbol> projectionFilter) {
Symbol a = planBuilder.symbol("a");
Symbol b = planBuilder.symbol("b");
Symbol key = planBuilder.symbol("key");
return planBuilder.project(Assignments.copyOf(ImmutableList.of(a, b).stream().filter(projectionFilter).collect(Collectors.toMap(v -> v, v -> planBuilder.variable(v.getName())))), planBuilder.aggregation(aggregationBuilder -> aggregationBuilder.source(planBuilder.values(key)).singleGroupingSet(key).addAggregation(a, PlanBuilder.expression("count()"), ImmutableList.of()).addAggregation(b, PlanBuilder.expression("count()"), ImmutableList.of())));
}
use of io.prestosql.spi.plan.ProjectNode in project hetu-core by openlookeng.
the class TestVerifyOnlyOneOutputNode method testValidateSuccessful.
@Test
public void testValidateSuccessful() {
// random seemingly valid plan
PlanNode root = new OutputNode(idAllocator.getNextId(), new ProjectNode(idAllocator.getNextId(), new ValuesNode(idAllocator.getNextId(), ImmutableList.of(), ImmutableList.of()), Assignments.of()), ImmutableList.of(), ImmutableList.of());
new VerifyOnlyOneOutputNode().validate(root, null, null, null, null, WarningCollector.NOOP);
}
use of io.prestosql.spi.plan.ProjectNode in project hetu-core by openlookeng.
the class TestVerifyOnlyOneOutputNode method testValidateFailed.
@Test(expectedExceptions = IllegalStateException.class)
public void testValidateFailed() {
// random plan with 2 output nodes
PlanNode root = new OutputNode(idAllocator.getNextId(), new ExplainAnalyzeNode(idAllocator.getNextId(), new OutputNode(idAllocator.getNextId(), new ProjectNode(idAllocator.getNextId(), new ValuesNode(idAllocator.getNextId(), ImmutableList.of(), ImmutableList.of()), Assignments.of()), ImmutableList.of(), ImmutableList.of()), new Symbol("a"), false), ImmutableList.of(), ImmutableList.of());
new VerifyOnlyOneOutputNode().validate(root, null, null, null, null, WarningCollector.NOOP);
}
use of io.prestosql.spi.plan.ProjectNode in project hetu-core by openlookeng.
the class TestRuleIndex method testWithPlanNodeHierarchy.
@Test
public void testWithPlanNodeHierarchy() {
Rule<?> projectRule1 = new NoOpRule<>(Pattern.typeOf(ProjectNode.class));
Rule<?> projectRule2 = new NoOpRule<>(Pattern.typeOf(ProjectNode.class));
Rule<?> filterRule = new NoOpRule<>(Pattern.typeOf(FilterNode.class));
Rule<?> anyRule = new NoOpRule<>(Pattern.any());
RuleIndex ruleIndex = RuleIndex.builder().register(projectRule1).register(projectRule2).register(filterRule).register(anyRule).build();
ProjectNode projectNode = planBuilder.project(Assignments.of(), planBuilder.values());
FilterNode filterNode = planBuilder.filter(BooleanLiteral.TRUE_LITERAL, planBuilder.values());
ValuesNode valuesNode = planBuilder.values();
assertEquals(ruleIndex.getCandidates(projectNode).collect(toSet()), ImmutableSet.of(projectRule1, projectRule2, anyRule));
assertEquals(ruleIndex.getCandidates(filterNode).collect(toSet()), ImmutableSet.of(filterRule, anyRule));
assertEquals(ruleIndex.getCandidates(valuesNode).collect(toSet()), ImmutableSet.of(anyRule));
}
use of io.prestosql.spi.plan.ProjectNode in project hetu-core by openlookeng.
the class TestPruneLimitColumns method buildProjectedLimit.
private ProjectNode buildProjectedLimit(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(), BIGINT)))), planBuilder.limit(1, planBuilder.values(a, b)));
}
Aggregations