Search in sources :

Example 1 with GATHER

use of com.facebook.presto.sql.planner.plan.ExchangeNode.Type.GATHER in project presto by prestodb.

the class TestUnion method testUnionUnderTopN.

@Test
public void testUnionUnderTopN() {
    Plan plan = plan("SELECT * FROM (" + "   SELECT regionkey FROM nation " + "   UNION ALL " + "   SELECT nationkey FROM nation" + ") t(a) " + "ORDER BY a LIMIT 1", LogicalPlanner.Stage.OPTIMIZED_AND_VALIDATED, false);
    List<PlanNode> remotes = searchFrom(plan.getRoot()).where(TestUnion::isRemoteExchange).findAll();
    assertEquals(remotes.size(), 1, "There should be exactly one RemoteExchange");
    assertEquals(((ExchangeNode) Iterables.getOnlyElement(remotes)).getType(), GATHER);
    int numberOfpartialTopN = searchFrom(plan.getRoot()).where(planNode -> planNode instanceof TopNNode && ((TopNNode) planNode).getStep().equals(TopNNode.Step.PARTIAL)).count();
    assertEquals(numberOfpartialTopN, 2, "There should be exactly two partial TopN nodes");
    assertPlanIsFullyDistributed(plan);
}
Also used : JoinNode(com.facebook.presto.sql.planner.plan.JoinNode) Iterables(com.google.common.collect.Iterables) AggregationNode(com.facebook.presto.spi.plan.AggregationNode) GATHER(com.facebook.presto.sql.planner.plan.ExchangeNode.Type.GATHER) BasePlanTest(com.facebook.presto.sql.planner.assertions.BasePlanTest) Assert.assertEquals(org.testng.Assert.assertEquals) Test(org.testng.annotations.Test) PlanNode(com.facebook.presto.spi.plan.PlanNode) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) REPARTITION(com.facebook.presto.sql.planner.plan.ExchangeNode.Type.REPARTITION) TopNNode(com.facebook.presto.spi.plan.TopNNode) Map(java.util.Map) Assert.assertTrue(org.testng.Assert.assertTrue) Plan(com.facebook.presto.sql.planner.Plan) Assert.assertFalse(org.testng.Assert.assertFalse) LogicalPlanner(com.facebook.presto.sql.planner.LogicalPlanner) PlanNodeSearcher.searchFrom(com.facebook.presto.sql.planner.optimizations.PlanNodeSearcher.searchFrom) ExchangeNode(com.facebook.presto.sql.planner.plan.ExchangeNode) PlanNode(com.facebook.presto.spi.plan.PlanNode) Plan(com.facebook.presto.sql.planner.Plan) TopNNode(com.facebook.presto.spi.plan.TopNNode) BasePlanTest(com.facebook.presto.sql.planner.assertions.BasePlanTest) Test(org.testng.annotations.Test)

Aggregations

AggregationNode (com.facebook.presto.spi.plan.AggregationNode)1 PlanNode (com.facebook.presto.spi.plan.PlanNode)1 TopNNode (com.facebook.presto.spi.plan.TopNNode)1 LogicalPlanner (com.facebook.presto.sql.planner.LogicalPlanner)1 Plan (com.facebook.presto.sql.planner.Plan)1 BasePlanTest (com.facebook.presto.sql.planner.assertions.BasePlanTest)1 PlanNodeSearcher.searchFrom (com.facebook.presto.sql.planner.optimizations.PlanNodeSearcher.searchFrom)1 ExchangeNode (com.facebook.presto.sql.planner.plan.ExchangeNode)1 GATHER (com.facebook.presto.sql.planner.plan.ExchangeNode.Type.GATHER)1 REPARTITION (com.facebook.presto.sql.planner.plan.ExchangeNode.Type.REPARTITION)1 JoinNode (com.facebook.presto.sql.planner.plan.JoinNode)1 Iterables (com.google.common.collect.Iterables)1 List (java.util.List)1 Map (java.util.Map)1 Collectors.toList (java.util.stream.Collectors.toList)1 Assert.assertEquals (org.testng.Assert.assertEquals)1 Assert.assertFalse (org.testng.Assert.assertFalse)1 Assert.assertTrue (org.testng.Assert.assertTrue)1 Test (org.testng.annotations.Test)1