Search in sources :

Example 41 with ProjectionPlanNode

use of org.voltdb.plannodes.ProjectionPlanNode in project voltdb by VoltDB.

the class TestPlansScalarSubQueries method testSelectCorrelatedScalarWithGroupby.

public void testSelectCorrelatedScalarWithGroupby() {
    String sql = "select franchise_id, count(*) as stores_in_category_AdHoc, " + " (select category from store_types where type_id = stores.type_id) as store_category " + "from stores group by franchise_id, type_id;";
    AbstractPlanNode pn = compile(sql);
    pn = pn.getChild(0);
    assertTrue(pn instanceof ProjectionPlanNode);
    NodeSchema schema = pn.getOutputSchema();
    assertEquals(3, schema.size());
    SchemaColumn col = schema.getColumns().get(2);
    assertTrue(col != null);
    assertEquals("STORE_CATEGORY", col.getColumnName());
    assertTrue(col.getExpression() instanceof ScalarValueExpression);
    pn = pn.getChild(0);
    assertTrue(pn instanceof AbstractScanPlanNode);
    assertNotNull(pn.getInlinePlanNode(PlanNodeType.HASHAGGREGATE));
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode) AbstractScanPlanNode(org.voltdb.plannodes.AbstractScanPlanNode) ScalarValueExpression(org.voltdb.expressions.ScalarValueExpression) SchemaColumn(org.voltdb.plannodes.SchemaColumn) NodeSchema(org.voltdb.plannodes.NodeSchema) ProjectionPlanNode(org.voltdb.plannodes.ProjectionPlanNode)

Example 42 with ProjectionPlanNode

use of org.voltdb.plannodes.ProjectionPlanNode in project voltdb by VoltDB.

the class TestPlansScalarSubQueries method testSelectCorrelatedScalarInGroupbyClause.

public void testSelectCorrelatedScalarInGroupbyClause() {
    String sql = "select franchise_id, count(*) as stores_in_category_AdHoc " + " from stores group by franchise_id, (select category from store_types where type_id = stores.type_id);";
    AbstractPlanNode pn = compile(sql);
    pn = pn.getChild(0);
    assertTrue(pn instanceof ProjectionPlanNode);
    NodeSchema schema = pn.getOutputSchema();
    assertEquals(2, schema.size());
    pn = pn.getChild(0);
    assertTrue(pn instanceof AbstractScanPlanNode);
    assertNotNull(pn.getInlinePlanNode(PlanNodeType.HASHAGGREGATE));
    HashAggregatePlanNode aggNode = (HashAggregatePlanNode) pn.getInlinePlanNode(PlanNodeType.HASHAGGREGATE);
    assertEquals(2, aggNode.getGroupByExpressionsSize());
    AbstractExpression tveExpr = aggNode.getGroupByExpressions().get(0);
    assertTrue(tveExpr instanceof TupleValueExpression);
    AbstractExpression gbExpr = aggNode.getGroupByExpressions().get(1);
    assertTrue(gbExpr instanceof ScalarValueExpression);
    assertTrue(gbExpr.getLeft() instanceof SelectSubqueryExpression);
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode) AbstractScanPlanNode(org.voltdb.plannodes.AbstractScanPlanNode) TupleValueExpression(org.voltdb.expressions.TupleValueExpression) AbstractExpression(org.voltdb.expressions.AbstractExpression) ScalarValueExpression(org.voltdb.expressions.ScalarValueExpression) HashAggregatePlanNode(org.voltdb.plannodes.HashAggregatePlanNode) SelectSubqueryExpression(org.voltdb.expressions.SelectSubqueryExpression) NodeSchema(org.voltdb.plannodes.NodeSchema) ProjectionPlanNode(org.voltdb.plannodes.ProjectionPlanNode)

Example 43 with ProjectionPlanNode

use of org.voltdb.plannodes.ProjectionPlanNode in project voltdb by VoltDB.

the class TestPlansLimit method checkInlineLimitAndOrderbyWithReceive.

private void checkInlineLimitAndOrderbyWithReceive(List<AbstractPlanNode> pns, boolean pushdown) {
    AbstractPlanNode p;
    p = pns.get(0).getChild(0);
    assertTrue(p instanceof ProjectionPlanNode);
    p = p.getChild(0);
    assertTrue(p instanceof MergeReceivePlanNode);
    assertNotNull(p.getInlinePlanNode(PlanNodeType.LIMIT));
    assertNotNull(p.getInlinePlanNode(PlanNodeType.ORDERBY));
    if (pushdown) {
        assertEquals(2, pns.size());
        p = pns.get(1).getChild(0);
        assertTrue(p instanceof OrderByPlanNode);
        assertNotNull(p.getInlinePlanNode(PlanNodeType.LIMIT));
    } else if (pns.size() == 2) {
        p = pns.get(1).getChild(0);
        assertFalse(p.toExplainPlanString().toLowerCase().contains("limit"));
    }
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode) OrderByPlanNode(org.voltdb.plannodes.OrderByPlanNode) MergeReceivePlanNode(org.voltdb.plannodes.MergeReceivePlanNode) ProjectionPlanNode(org.voltdb.plannodes.ProjectionPlanNode)

Example 44 with ProjectionPlanNode

use of org.voltdb.plannodes.ProjectionPlanNode in project voltdb by VoltDB.

the class TestPlansSubQueries method checkReplicatedOne.

private void checkReplicatedOne(String sql) {
    AbstractPlanNode pn;
    List<AbstractPlanNode> planNodes;
    AbstractPlanNode nlpn;
    planNodes = compileToFragments(sql);
    assertEquals(1, planNodes.size());
    pn = planNodes.get(0);
    assertTrue(pn instanceof SendPlanNode);
    pn = pn.getChild(0);
    assertTrue(pn instanceof ProjectionPlanNode);
    nlpn = pn.getChild(0);
    assertTrue(nlpn instanceof NestLoopPlanNode);
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode) SendPlanNode(org.voltdb.plannodes.SendPlanNode) NestLoopPlanNode(org.voltdb.plannodes.NestLoopPlanNode) ProjectionPlanNode(org.voltdb.plannodes.ProjectionPlanNode)

Example 45 with ProjectionPlanNode

use of org.voltdb.plannodes.ProjectionPlanNode in project voltdb by VoltDB.

the class TestPlansGroupBy method testEdgeComplexRelatedCases.

public void testEdgeComplexRelatedCases() {
    List<AbstractPlanNode> pns;
    pns = compileToFragments("select PKEY+A1 from T1 Order by PKEY+A1");
    AbstractPlanNode p = pns.get(0).getChild(0);
    assertTrue(p instanceof ProjectionPlanNode);
    assertTrue(p.getChild(0) instanceof OrderByPlanNode);
    assertTrue(p.getChild(0).getChild(0) instanceof ReceivePlanNode);
    p = pns.get(1).getChild(0);
    assertTrue(p instanceof AbstractScanPlanNode);
    // Useless order by clause.
    pns = compileToFragments("SELECT count(*)  FROM P1 order by PKEY");
    p = pns.get(0).getChild(0);
    assertTrue(p instanceof AggregatePlanNode);
    assertTrue(p.getChild(0) instanceof ReceivePlanNode);
    p = pns.get(1).getChild(0);
    assertTrue(p instanceof AbstractScanPlanNode);
    pns = compileToFragments("SELECT A1, count(*) as tag FROM P1 group by A1 order by tag, A1 limit 1");
    p = pns.get(0).getChild(0);
    // ENG-5066: now Limit is pushed under Projection
    // Limit is also inlined with Orderby node
    assertTrue(p instanceof ProjectionPlanNode);
    p = p.getChild(0);
    assertTrue(p instanceof OrderByPlanNode);
    assertNotNull(p.getInlinePlanNode(PlanNodeType.LIMIT));
    assertTrue(p.getChild(0) instanceof AggregatePlanNode);
    p = pns.get(1).getChild(0);
    // inline aggregate
    assertTrue(p instanceof AbstractScanPlanNode);
    assertNotNull(p.getInlinePlanNode(PlanNodeType.HASHAGGREGATE));
    pns = compileToFragments("SELECT F_D1, count(*) as tag FROM RF group by F_D1 order by tag");
    p = pns.get(0).getChild(0);
    //* enable to debug */ System.out.println("DEBUG: " + p.toExplainPlanString());
    assertTrue(p instanceof ProjectionPlanNode);
    p = p.getChild(0);
    assertTrue(p instanceof OrderByPlanNode);
    p = p.getChild(0);
    assertTrue(p instanceof IndexScanPlanNode);
    assertNotNull(p.getInlinePlanNode(PlanNodeType.AGGREGATE));
    pns = compileToFragments("SELECT F_D1, count(*) FROM RF group by F_D1 order by 2");
    p = pns.get(0).getChild(0);
    //* enable to debug */ System.out.println("DEBUG: " + p.toExplainPlanString());
    assertTrue(p instanceof ProjectionPlanNode);
    p = p.getChild(0);
    assertTrue(p instanceof OrderByPlanNode);
    p = p.getChild(0);
    assertTrue(p instanceof IndexScanPlanNode);
    assertNotNull(p.getInlinePlanNode(PlanNodeType.AGGREGATE));
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode) AbstractScanPlanNode(org.voltdb.plannodes.AbstractScanPlanNode) OrderByPlanNode(org.voltdb.plannodes.OrderByPlanNode) HashAggregatePlanNode(org.voltdb.plannodes.HashAggregatePlanNode) AggregatePlanNode(org.voltdb.plannodes.AggregatePlanNode) IndexScanPlanNode(org.voltdb.plannodes.IndexScanPlanNode) ReceivePlanNode(org.voltdb.plannodes.ReceivePlanNode) AbstractReceivePlanNode(org.voltdb.plannodes.AbstractReceivePlanNode) ProjectionPlanNode(org.voltdb.plannodes.ProjectionPlanNode)

Aggregations

ProjectionPlanNode (org.voltdb.plannodes.ProjectionPlanNode)51 AbstractPlanNode (org.voltdb.plannodes.AbstractPlanNode)48 OrderByPlanNode (org.voltdb.plannodes.OrderByPlanNode)25 HashAggregatePlanNode (org.voltdb.plannodes.HashAggregatePlanNode)17 SendPlanNode (org.voltdb.plannodes.SendPlanNode)16 AbstractScanPlanNode (org.voltdb.plannodes.AbstractScanPlanNode)14 AggregatePlanNode (org.voltdb.plannodes.AggregatePlanNode)14 MergeReceivePlanNode (org.voltdb.plannodes.MergeReceivePlanNode)13 NestLoopPlanNode (org.voltdb.plannodes.NestLoopPlanNode)13 ReceivePlanNode (org.voltdb.plannodes.ReceivePlanNode)13 AbstractExpression (org.voltdb.expressions.AbstractExpression)10 NodeSchema (org.voltdb.plannodes.NodeSchema)9 SeqScanPlanNode (org.voltdb.plannodes.SeqScanPlanNode)9 IndexScanPlanNode (org.voltdb.plannodes.IndexScanPlanNode)8 SchemaColumn (org.voltdb.plannodes.SchemaColumn)7 TupleValueExpression (org.voltdb.expressions.TupleValueExpression)5 AbstractReceivePlanNode (org.voltdb.plannodes.AbstractReceivePlanNode)5 LimitPlanNode (org.voltdb.plannodes.LimitPlanNode)4 NestLoopIndexPlanNode (org.voltdb.plannodes.NestLoopIndexPlanNode)4 Table (org.voltdb.catalog.Table)3