Search in sources :

Example 6 with ValuesNode

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));
}
Also used : ValuesNode(io.prestosql.spi.plan.ValuesNode) FilterNode(io.prestosql.spi.plan.FilterNode) ProjectNode(io.prestosql.spi.plan.ProjectNode) Test(org.testng.annotations.Test)

Example 7 with ValuesNode

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);
}
Also used : ValuesNode(io.prestosql.spi.plan.ValuesNode) Symbol(io.prestosql.spi.plan.Symbol) MultiJoinNode.toMultiJoinNode(io.prestosql.sql.planner.iterative.rule.ReorderJoins.MultiJoinNode.toMultiJoinNode) JoinNode(io.prestosql.spi.plan.JoinNode) MultiJoinNode(io.prestosql.sql.planner.iterative.rule.ReorderJoins.MultiJoinNode) PlanBuilder(io.prestosql.sql.planner.iterative.rule.test.PlanBuilder) MultiJoinNode.toMultiJoinNode(io.prestosql.sql.planner.iterative.rule.ReorderJoins.MultiJoinNode.toMultiJoinNode) MultiJoinNode(io.prestosql.sql.planner.iterative.rule.ReorderJoins.MultiJoinNode) Test(org.testng.annotations.Test)

Example 8 with ValuesNode

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);
}
Also used : ValuesNode(io.prestosql.spi.plan.ValuesNode) Symbol(io.prestosql.spi.plan.Symbol) MultiJoinNode.toMultiJoinNode(io.prestosql.sql.planner.iterative.rule.ReorderJoins.MultiJoinNode.toMultiJoinNode) JoinNode(io.prestosql.spi.plan.JoinNode) MultiJoinNode(io.prestosql.sql.planner.iterative.rule.ReorderJoins.MultiJoinNode) PlanBuilder(io.prestosql.sql.planner.iterative.rule.test.PlanBuilder) MultiJoinNode.toMultiJoinNode(io.prestosql.sql.planner.iterative.rule.ReorderJoins.MultiJoinNode.toMultiJoinNode) MultiJoinNode(io.prestosql.sql.planner.iterative.rule.ReorderJoins.MultiJoinNode) Test(org.testng.annotations.Test)

Example 9 with ValuesNode

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);
}
Also used : ValuesNode(io.prestosql.spi.plan.ValuesNode) Symbol(io.prestosql.spi.plan.Symbol) MultiJoinNode.toMultiJoinNode(io.prestosql.sql.planner.iterative.rule.ReorderJoins.MultiJoinNode.toMultiJoinNode) JoinNode(io.prestosql.spi.plan.JoinNode) MultiJoinNode(io.prestosql.sql.planner.iterative.rule.ReorderJoins.MultiJoinNode) PlanBuilder(io.prestosql.sql.planner.iterative.rule.test.PlanBuilder) MultiJoinNode.toMultiJoinNode(io.prestosql.sql.planner.iterative.rule.ReorderJoins.MultiJoinNode.toMultiJoinNode) MultiJoinNode(io.prestosql.sql.planner.iterative.rule.ReorderJoins.MultiJoinNode) Test(org.testng.annotations.Test)

Example 10 with ValuesNode

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);
}
Also used : ValuesNode(io.prestosql.spi.plan.ValuesNode) OutputNode(io.prestosql.sql.planner.plan.OutputNode) PlanNode(io.prestosql.spi.plan.PlanNode) Symbol(io.prestosql.spi.plan.Symbol) CreateTableAsSelect(io.prestosql.sql.tree.CreateTableAsSelect) ConstantExpression(io.prestosql.spi.relation.ConstantExpression)

Aggregations

ValuesNode (io.prestosql.spi.plan.ValuesNode)26 Symbol (io.prestosql.spi.plan.Symbol)16 Test (org.testng.annotations.Test)12 PlanNode (io.prestosql.spi.plan.PlanNode)8 RowExpression (io.prestosql.spi.relation.RowExpression)8 List (java.util.List)8 ImmutableList (com.google.common.collect.ImmutableList)6 JoinNode (io.prestosql.spi.plan.JoinNode)6 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)5 ProjectNode (io.prestosql.spi.plan.ProjectNode)5 MultiJoinNode (io.prestosql.sql.planner.iterative.rule.ReorderJoins.MultiJoinNode)5 MultiJoinNode.toMultiJoinNode (io.prestosql.sql.planner.iterative.rule.ReorderJoins.MultiJoinNode.toMultiJoinNode)5 PlanBuilder (io.prestosql.sql.planner.iterative.rule.test.PlanBuilder)5 ImmutableMap (com.google.common.collect.ImmutableMap)4 ConstantExpression (io.prestosql.spi.relation.ConstantExpression)4 ComparisonExpression (io.prestosql.sql.tree.ComparisonExpression)4 Session (io.prestosql.Session)3 OutputNode (io.prestosql.sql.planner.plan.OutputNode)3 OriginalExpressionUtils.castToRowExpression (io.prestosql.sql.relational.OriginalExpressionUtils.castToRowExpression)3 Expression (io.prestosql.sql.tree.Expression)3