use of io.prestosql.spi.plan.ValuesNode 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.ValuesNode in project hetu-core by openlookeng.
the class TestJoinNodeFlattener method testMoreThanJoinLimit.
@Test
public void testMoreThanJoinLimit() {
PlanBuilder p = planBuilder();
Symbol a1 = p.symbol("A1");
Symbol b1 = p.symbol("B1");
Symbol c1 = p.symbol("C1");
Symbol d1 = p.symbol("D1");
Symbol d2 = p.symbol("D2");
Symbol e1 = p.symbol("E1");
Symbol e2 = p.symbol("E2");
ValuesNode valuesA = p.values(a1);
ValuesNode valuesB = p.values(b1);
ValuesNode valuesC = p.values(c1);
ValuesNode valuesD = p.values(d1, d2);
ValuesNode valuesE = p.values(e1, e2);
JoinNode join1 = p.join(INNER, valuesA, valuesB, ImmutableList.of(equiJoinClause(a1, b1)), ImmutableList.of(a1, b1), Optional.empty());
JoinNode join2 = p.join(INNER, valuesD, valuesE, ImmutableList.of(equiJoinClause(d1, e1), equiJoinClause(d2, e2)), ImmutableList.of(d1, d2, e1, e2), Optional.empty());
JoinNode joinNode = p.join(INNER, p.join(INNER, join1, valuesC, ImmutableList.of(equiJoinClause(a1, c1)), ImmutableList.of(a1, b1, c1), Optional.empty()), join2, ImmutableList.of(equiJoinClause(b1, e1)), ImmutableList.of(a1, b1, c1, d1, d2, e1, e2), Optional.empty());
MultiJoinNode expected = MultiJoinNode.builder().setSources(join1, join2, valuesC).setFilter(logicalRowExpressions.and(createEqualsExpression(a1, c1, p.getTypes()), createEqualsExpression(b1, e1, p.getTypes()))).setOutputSymbols(a1, b1, c1, d1, d2, e1, e2).setLogicalRowExpressions(logicalRowExpressions).build();
assertEquals(toMultiJoinNode(joinNode, noLookup(), 2, queryRunner.getMetadata(), p.getTypes(), logicalRowExpressions), expected);
}
use of io.prestosql.spi.plan.ValuesNode in project hetu-core by openlookeng.
the class TestJoinNodeFlattener method testConvertsBushyTrees.
@Test
public void testConvertsBushyTrees() {
PlanBuilder p = planBuilder();
Symbol a1 = p.symbol("A1");
Symbol b1 = p.symbol("B1");
Symbol c1 = p.symbol("C1");
Symbol d1 = p.symbol("D1");
Symbol d2 = p.symbol("D2");
Symbol e1 = p.symbol("E1");
Symbol e2 = p.symbol("E2");
ValuesNode valuesA = p.values(a1);
ValuesNode valuesB = p.values(b1);
ValuesNode valuesC = p.values(c1);
ValuesNode valuesD = p.values(d1, d2);
ValuesNode valuesE = p.values(e1, e2);
JoinNode joinNode = p.join(INNER, p.join(INNER, p.join(INNER, valuesA, valuesB, ImmutableList.of(equiJoinClause(a1, b1)), ImmutableList.of(a1, b1), Optional.empty()), valuesC, ImmutableList.of(equiJoinClause(a1, c1)), ImmutableList.of(a1, b1, c1), Optional.empty()), p.join(INNER, valuesD, valuesE, ImmutableList.of(equiJoinClause(d1, e1), equiJoinClause(d2, e2)), ImmutableList.of(d1, d2, e1, e2), Optional.empty()), ImmutableList.of(equiJoinClause(b1, e1)), ImmutableList.of(a1, b1, c1, d1, d2, e1, e2), Optional.empty());
MultiJoinNode expected = MultiJoinNode.builder().setSources(valuesA, valuesB, valuesC, valuesD, valuesE).setFilter(logicalRowExpressions.and(createEqualsExpression(a1, b1, p.getTypes()), createEqualsExpression(a1, c1, p.getTypes()), createEqualsExpression(d1, e1, p.getTypes()), createEqualsExpression(d2, e2, p.getTypes()), createEqualsExpression(b1, e1, p.getTypes()))).setOutputSymbols(a1, b1, c1, d1, d2, e1, e2).setLogicalRowExpressions(logicalRowExpressions).build();
assertEquals(toMultiJoinNode(joinNode, noLookup(), 5, queryRunner.getMetadata(), p.getTypes(), logicalRowExpressions), expected);
}
use of io.prestosql.spi.plan.ValuesNode in project hetu-core by openlookeng.
the class TestJoinNodeFlattener method testRetainsOutputSymbols.
@Test
public void testRetainsOutputSymbols() {
PlanBuilder p = planBuilder();
Symbol a1 = p.symbol("A1");
Symbol b1 = p.symbol("B1");
Symbol b2 = p.symbol("B2");
Symbol c1 = p.symbol("C1");
Symbol c2 = p.symbol("C2");
ValuesNode valuesA = p.values(a1);
ValuesNode valuesB = p.values(b1, b2);
ValuesNode valuesC = p.values(c1, c2);
JoinNode joinNode = p.join(INNER, valuesA, p.join(INNER, valuesB, valuesC, ImmutableList.of(equiJoinClause(b1, c1)), ImmutableList.of(b1, b2, c1, c2), Optional.empty()), ImmutableList.of(equiJoinClause(a1, b1)), ImmutableList.of(a1, b1), Optional.empty());
MultiJoinNode expected = MultiJoinNode.builder().setSources(valuesA, valuesB, valuesC).setFilter(logicalRowExpressions.and(createEqualsExpression(b1, c1, p.getTypes()), createEqualsExpression(a1, b1, p.getTypes()))).setOutputSymbols(a1, b1).setLogicalRowExpressions(logicalRowExpressions).build();
assertEquals(toMultiJoinNode(joinNode, noLookup(), DEFAULT_JOIN_LIMIT, queryRunner.getMetadata(), p.getTypes(), logicalRowExpressions), expected);
}
use of io.prestosql.spi.plan.ValuesNode in project hetu-core by openlookeng.
the class LogicalPlanner method planStatement.
public PlanNode planStatement(Analysis analysis, Statement statement) {
if ((statement instanceof CreateTableAsSelect) && analysis.isCreateTableAsSelectNoOp()) {
checkState(analysis.getCreateTableDestination().isPresent(), "Table destination is missing");
Symbol symbol = planSymbolAllocator.newSymbol("rows", BIGINT);
PlanNode source = new ValuesNode(idAllocator.getNextId(), ImmutableList.of(symbol), ImmutableList.of(ImmutableList.of(new ConstantExpression(0L, BIGINT))));
return new OutputNode(idAllocator.getNextId(), source, ImmutableList.of("rows"), ImmutableList.of(symbol));
}
return createOutputPlan(planStatementWithoutOutput(analysis, statement), analysis);
}
Aggregations