Search in sources :

Example 1 with MultiJoinNode

use of io.prestosql.sql.planner.iterative.rule.ReorderJoins.MultiJoinNode 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 2 with MultiJoinNode

use of io.prestosql.sql.planner.iterative.rule.ReorderJoins.MultiJoinNode 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 3 with MultiJoinNode

use of io.prestosql.sql.planner.iterative.rule.ReorderJoins.MultiJoinNode 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 4 with MultiJoinNode

use of io.prestosql.sql.planner.iterative.rule.ReorderJoins.MultiJoinNode in project hetu-core by openlookeng.

the class TestJoinEnumerator method testDoesNotCreateJoinWhenPartitionedOnCrossJoin.

@Test
public void testDoesNotCreateJoinWhenPartitionedOnCrossJoin() {
    PlanNodeIdAllocator idAllocator = new PlanNodeIdAllocator();
    PlanBuilder p = new PlanBuilder(idAllocator, queryRunner.getMetadata());
    Symbol a1 = p.symbol("A1");
    Symbol b1 = p.symbol("B1");
    LogicalRowExpressions logicalRowExpressions = new LogicalRowExpressions(new RowExpressionDeterminismEvaluator(queryRunner.getMetadata()), new FunctionResolution(queryRunner.getMetadata().getFunctionAndTypeManager()), queryRunner.getMetadata().getFunctionAndTypeManager());
    MultiJoinNode multiJoinNode = new MultiJoinNode(new LinkedHashSet<>(ImmutableList.of(p.values(a1), p.values(b1))), TRUE_CONSTANT, ImmutableList.of(a1, b1), logicalRowExpressions);
    JoinEnumerator joinEnumerator = new JoinEnumerator(new CostComparator(1, 1, 1), multiJoinNode.getFilter(), createContext(), queryRunner.getMetadata(), logicalRowExpressions);
    JoinEnumerationResult actual = joinEnumerator.createJoinAccordingToPartitioning(multiJoinNode.getSources(), multiJoinNode.getOutputSymbols(), ImmutableSet.of(0));
    assertFalse(actual.getPlanNode().isPresent());
    assertEquals(actual.getCost(), PlanCostEstimate.infinite());
}
Also used : CostComparator(io.prestosql.cost.CostComparator) RowExpressionDeterminismEvaluator(io.prestosql.sql.relational.RowExpressionDeterminismEvaluator) JoinEnumerator(io.prestosql.sql.planner.iterative.rule.ReorderJoins.JoinEnumerator) PlanNodeIdAllocator(io.prestosql.spi.plan.PlanNodeIdAllocator) Symbol(io.prestosql.spi.plan.Symbol) LogicalRowExpressions(io.prestosql.expressions.LogicalRowExpressions) JoinEnumerationResult(io.prestosql.sql.planner.iterative.rule.ReorderJoins.JoinEnumerationResult) PlanBuilder(io.prestosql.sql.planner.iterative.rule.test.PlanBuilder) FunctionResolution(io.prestosql.sql.relational.FunctionResolution) MultiJoinNode(io.prestosql.sql.planner.iterative.rule.ReorderJoins.MultiJoinNode) Test(org.testng.annotations.Test)

Example 5 with MultiJoinNode

use of io.prestosql.sql.planner.iterative.rule.ReorderJoins.MultiJoinNode in project hetu-core by openlookeng.

the class TestJoinNodeFlattener method testDoesNotConvertNestedOuterJoins.

@Test
public void testDoesNotConvertNestedOuterJoins() {
    PlanBuilder p = planBuilder();
    Symbol a1 = p.symbol("A1");
    Symbol b1 = p.symbol("B1");
    Symbol c1 = p.symbol("C1");
    JoinNode leftJoin = p.join(LEFT, p.values(a1), p.values(b1), ImmutableList.of(equiJoinClause(a1, b1)), ImmutableList.of(a1, b1), Optional.empty());
    ValuesNode valuesC = p.values(c1);
    JoinNode joinNode = p.join(INNER, leftJoin, valuesC, ImmutableList.of(equiJoinClause(a1, c1)), ImmutableList.of(a1, b1, c1), Optional.empty());
    MultiJoinNode expected = MultiJoinNode.builder().setSources(leftJoin, valuesC).setFilter(createEqualsExpression(a1, c1, p.getTypes())).setOutputSymbols(a1, b1, c1).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)

Aggregations

Symbol (io.prestosql.spi.plan.Symbol)5 MultiJoinNode (io.prestosql.sql.planner.iterative.rule.ReorderJoins.MultiJoinNode)5 PlanBuilder (io.prestosql.sql.planner.iterative.rule.test.PlanBuilder)5 Test (org.testng.annotations.Test)5 JoinNode (io.prestosql.spi.plan.JoinNode)4 ValuesNode (io.prestosql.spi.plan.ValuesNode)4 MultiJoinNode.toMultiJoinNode (io.prestosql.sql.planner.iterative.rule.ReorderJoins.MultiJoinNode.toMultiJoinNode)4 CostComparator (io.prestosql.cost.CostComparator)1 LogicalRowExpressions (io.prestosql.expressions.LogicalRowExpressions)1 PlanNodeIdAllocator (io.prestosql.spi.plan.PlanNodeIdAllocator)1 JoinEnumerationResult (io.prestosql.sql.planner.iterative.rule.ReorderJoins.JoinEnumerationResult)1 JoinEnumerator (io.prestosql.sql.planner.iterative.rule.ReorderJoins.JoinEnumerator)1 FunctionResolution (io.prestosql.sql.relational.FunctionResolution)1 RowExpressionDeterminismEvaluator (io.prestosql.sql.relational.RowExpressionDeterminismEvaluator)1