Search in sources :

Example 31 with PlanNode

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);
}
Also used : PlanNode(io.prestosql.spi.plan.PlanNode) UnionNode(io.prestosql.spi.plan.UnionNode) Symbol(io.prestosql.spi.plan.Symbol) Test(org.testng.annotations.Test)

Example 32 with PlanNode

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));
}
Also used : PlanNode(io.prestosql.spi.plan.PlanNode) JoinGraph(io.prestosql.sql.planner.optimizations.joins.JoinGraph) BaseRuleTest(io.prestosql.sql.planner.iterative.rule.test.BaseRuleTest) Test(org.testng.annotations.Test)

Example 33 with PlanNode

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));
}
Also used : PlanNode(io.prestosql.spi.plan.PlanNode) JoinGraph(io.prestosql.sql.planner.optimizations.joins.JoinGraph) BaseRuleTest(io.prestosql.sql.planner.iterative.rule.test.BaseRuleTest) Test(org.testng.annotations.Test)

Example 34 with PlanNode

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));
}
Also used : PlanNode(io.prestosql.spi.plan.PlanNode) InputReferenceExpression(io.prestosql.spi.relation.InputReferenceExpression) UnionNode(io.prestosql.spi.plan.UnionNode) VariableReferenceExpression(io.prestosql.spi.relation.VariableReferenceExpression) Symbol(io.prestosql.spi.plan.Symbol) Assignments(io.prestosql.spi.plan.Assignments) ProjectNode(io.prestosql.spi.plan.ProjectNode) BaseRuleTest(io.prestosql.sql.planner.iterative.rule.test.BaseRuleTest) Test(org.testng.annotations.Test)

Example 35 with PlanNode

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);
}
Also used : PlanNode(io.prestosql.spi.plan.PlanNode) Plan(io.prestosql.sql.planner.Plan) BasePlanTest(io.prestosql.sql.planner.assertions.BasePlanTest) Test(org.testng.annotations.Test)

Aggregations

PlanNode (io.prestosql.spi.plan.PlanNode)241 Test (org.testng.annotations.Test)100 Symbol (io.prestosql.spi.plan.Symbol)98 RowExpression (io.prestosql.spi.relation.RowExpression)52 ImmutableList (com.google.common.collect.ImmutableList)49 ProjectNode (io.prestosql.spi.plan.ProjectNode)46 Expression (io.prestosql.sql.tree.Expression)46 TableScanNode (io.prestosql.spi.plan.TableScanNode)45 JoinNode (io.prestosql.spi.plan.JoinNode)42 Optional (java.util.Optional)42 OriginalExpressionUtils.castToRowExpression (io.prestosql.sql.relational.OriginalExpressionUtils.castToRowExpression)41 FilterNode (io.prestosql.spi.plan.FilterNode)39 CallExpression (io.prestosql.spi.relation.CallExpression)39 ImmutableMap (com.google.common.collect.ImmutableMap)38 List (java.util.List)38 Map (java.util.Map)36 AggregationNode (io.prestosql.spi.plan.AggregationNode)35 BasePlanTest (io.prestosql.sql.planner.assertions.BasePlanTest)34 Assignments (io.prestosql.spi.plan.Assignments)33 ComparisonExpression (io.prestosql.sql.tree.ComparisonExpression)32