Search in sources :

Example 6 with JoinGraph

use of com.facebook.presto.sql.planner.optimizations.joins.JoinGraph in project presto by prestodb.

the class TestEliminateCrossJoins method testJoinOrderWithRealCrossJoin.

@Test
public void testJoinOrderWithRealCrossJoin() {
    PlanNode leftPlan = join(join(values(symbol("a")), values(symbol("b"))), values(symbol("c")), symbol("a"), symbol("c"), symbol("c"), symbol("b"));
    PlanNode rightPlan = join(join(values(symbol("x")), values(symbol("y"))), values(symbol("z")), symbol("x"), symbol("z"), symbol("z"), symbol("y"));
    PlanNode plan = join(leftPlan, rightPlan);
    JoinGraph joinGraph = getOnlyElement(JoinGraph.buildFrom(plan));
    assertEquals(EliminateCrossJoins.getJoinOrder(joinGraph), ImmutableList.of(0, 2, 1, 3, 5, 4));
}
Also used : PlanNode(com.facebook.presto.sql.planner.plan.PlanNode) JoinGraph(com.facebook.presto.sql.planner.optimizations.joins.JoinGraph) Test(org.testng.annotations.Test)

Example 7 with JoinGraph

use of com.facebook.presto.sql.planner.optimizations.joins.JoinGraph in project presto by prestodb.

the class TestEliminateCrossJoins method testJoinOrderWithMultipleEdgesBetweenNodes.

@Test
public void testJoinOrderWithMultipleEdgesBetweenNodes() {
    PlanNode plan = join(join(values(symbol("a")), values(symbol("b1"), symbol("b2"))), values(symbol("c1"), symbol("c2")), symbol("a"), symbol("c1"), symbol("c1"), symbol("b1"), symbol("c2"), symbol("b2"));
    JoinGraph joinGraph = getOnlyElement(JoinGraph.buildFrom(plan));
    assertEquals(EliminateCrossJoins.getJoinOrder(joinGraph), ImmutableList.of(0, 2, 1));
}
Also used : PlanNode(com.facebook.presto.sql.planner.plan.PlanNode) JoinGraph(com.facebook.presto.sql.planner.optimizations.joins.JoinGraph) Test(org.testng.annotations.Test)

Aggregations

JoinGraph (com.facebook.presto.sql.planner.optimizations.joins.JoinGraph)7 PlanNode (com.facebook.presto.sql.planner.plan.PlanNode)6 Test (org.testng.annotations.Test)5 SimplePlanRewriter (com.facebook.presto.sql.planner.plan.SimplePlanRewriter)2 Session (com.facebook.presto.Session)1 SystemSessionProperties (com.facebook.presto.SystemSessionProperties)1 Type (com.facebook.presto.spi.type.Type)1 PlanNodeIdAllocator (com.facebook.presto.sql.planner.PlanNodeIdAllocator)1 Symbol (com.facebook.presto.sql.planner.Symbol)1 SymbolAllocator (com.facebook.presto.sql.planner.SymbolAllocator)1 Assignments (com.facebook.presto.sql.planner.plan.Assignments)1 FilterNode (com.facebook.presto.sql.planner.plan.FilterNode)1 JoinNode (com.facebook.presto.sql.planner.plan.JoinNode)1 PlanNodeId (com.facebook.presto.sql.planner.plan.PlanNodeId)1 ProjectNode (com.facebook.presto.sql.planner.plan.ProjectNode)1 SimplePlanRewriter.rewriteWith (com.facebook.presto.sql.planner.plan.SimplePlanRewriter.rewriteWith)1 Expression (com.facebook.presto.sql.tree.Expression)1 ImmutableCollectors.toImmutableList (com.facebook.presto.util.ImmutableCollectors.toImmutableList)1 Preconditions.checkState (com.google.common.base.Preconditions.checkState)1 ImmutableList (com.google.common.collect.ImmutableList)1