use of io.trino.sql.planner.LogicalPlanner.Stage.OPTIMIZED_AND_VALIDATED in project trino by trinodb.
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", 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() == TopNNode.Step.PARTIAL).count();
assertEquals(numberOfpartialTopN, 2, "There should be exactly two partial TopN nodes");
assertPlanIsFullyDistributed(plan);
}
Aggregations