use of io.prestosql.spi.plan.PlanNode in project hetu-core by openlookeng.
the class TestTypeValidator method testInvalidUnion.
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "type of symbol 'output(_[0-9]+)?' is expected to be date, but the actual type is bigint")
public void testInvalidUnion() {
Symbol outputSymbol = planSymbolAllocator.newSymbol("output", DATE);
ListMultimap<Symbol, Symbol> mappings = ImmutableListMultimap.<Symbol, Symbol>builder().put(outputSymbol, columnD).put(outputSymbol, // should be a symbol with DATE type
columnA).build();
PlanNode node = new UnionNode(newId(), ImmutableList.of(baseTableScan, baseTableScan), mappings, ImmutableList.copyOf(mappings.keySet()));
assertTypesValid(node);
}
use of io.prestosql.spi.plan.PlanNode in project hetu-core by openlookeng.
the class TestEliminateCrossJoins method testJoinOrder.
@Test
public void testJoinOrder() {
PlanNode plan = joinNode(joinNode(values(symbol("a")), values(symbol("b"))), values(symbol("c")), symbol("a"), symbol("c"), symbol("c"), symbol("b"));
JoinGraph joinGraph = getOnlyElement(JoinGraph.buildFrom(plan));
assertEquals(getJoinOrder(joinGraph), ImmutableList.of(0, 2, 1));
}
use of io.prestosql.spi.plan.PlanNode in project hetu-core by openlookeng.
the class TestEliminateCrossJoins method testDonNotChangeOrderWithoutCrossJoin.
@Test
public void testDonNotChangeOrderWithoutCrossJoin() {
PlanNode plan = joinNode(joinNode(values(symbol("a")), values(symbol("b")), symbol("a"), symbol("b")), values(symbol("c")), symbol("c"), symbol("b"));
JoinGraph joinGraph = getOnlyElement(JoinGraph.buildFrom(plan));
assertEquals(getJoinOrder(joinGraph), ImmutableList.of(0, 1, 2));
}
use of io.prestosql.spi.plan.PlanNode in project hetu-core by openlookeng.
the class TestStarTreeAggregationRule method testSupportedProjectNode.
@Test
public void testSupportedProjectNode() {
// node is projectNode and expression instance of cast
Assignments assignment1 = Assignments.builder().put(columnCustkey, new VariableReferenceExpression(columnCustkey.getName(), custkeyHandle.getType())).build();
Optional<PlanNode> planNode1 = Optional.of(new ProjectNode(newId(), baseTableScan, assignment1));
assertTrue(CubeOptimizerUtil.supportedProjectNode(planNode1));
// not projectNode
ListMultimap<Symbol, Symbol> mappings = ImmutableListMultimap.<Symbol, Symbol>builder().put(output, columnOrderkey).put(output, columnOrderkey).build();
Optional<PlanNode> planNode2 = Optional.of(new UnionNode(newId(), ImmutableList.of(baseTableScan, baseTableScan), mappings, ImmutableList.copyOf(mappings.keySet())));
assertFalse(CubeOptimizerUtil.supportedProjectNode(planNode2));
// expression not instance of Cast
Assignments assignment2 = Assignments.builder().put(columnCustkey, new InputReferenceExpression(1, INTEGER)).build();
Optional<PlanNode> planNode3 = Optional.of(new ProjectNode(newId(), baseTableScan, assignment2));
assertFalse(CubeOptimizerUtil.supportedProjectNode(planNode3));
// expression is instance of SymbolReference OR Literal
Assignments assignment3 = Assignments.builder().put(columnCustkey, // should be INTEGER
new VariableReferenceExpression(columnCustkey.getName(), custkeyHandle.getType())).build();
Optional<PlanNode> planNode4 = Optional.of(new ProjectNode(newId(), baseTableScan, assignment3));
assertTrue(CubeOptimizerUtil.supportedProjectNode(planNode4));
// empty node
Optional<PlanNode> emptyPlanNode = Optional.empty();
assertTrue(CubeOptimizerUtil.supportedProjectNode(emptyPlanNode));
}
use of io.prestosql.spi.plan.PlanNode in project hetu-core by openlookeng.
the class TestUnion method testUnionOverSingleNodeAggregationAndUnion.
@Test
public void testUnionOverSingleNodeAggregationAndUnion() {
Plan plan = plan("SELECT count(*) FROM (" + "SELECT 1 FROM nation GROUP BY regionkey " + "UNION ALL (" + " SELECT 1 FROM nation " + " UNION ALL " + " SELECT 1 FROM nation))", LogicalPlanner.Stage.OPTIMIZED_AND_VALIDATED, false);
List<PlanNode> remotes = searchFrom(plan.getRoot()).where(TestUnion::isRemoteExchange).findAll();
assertEquals(remotes.size(), 2, "There should be exactly two RemoteExchanges");
assertEquals(((ExchangeNode) remotes.get(0)).getType(), GATHER);
assertEquals(((ExchangeNode) remotes.get(1)).getType(), REPARTITION);
}
Aggregations