Search in sources :

Example 31 with AggregatePlanNode

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

the class TestPlansCount method testCountStar21.

// test with group by with Partitioned table
public void testCountStar21() {
    List<AbstractPlanNode> pn = compileToFragments("SELECT RATIO, count(*) from P1 WHERE NUM < 1 Group by RATIO");
    for (AbstractPlanNode nd : pn) System.out.println("PlanNode Explain string:\n" + nd.toExplainPlanString());
    AbstractPlanNode p = pn.get(0).getChild(0);
    assertTrue(p instanceof AggregatePlanNode);
    p = pn.get(1).getChild(0);
    assertTrue(p instanceof IndexScanPlanNode);
    assertTrue(p.getInlinePlanNode(PlanNodeType.AGGREGATE) != null || p.getInlinePlanNode(PlanNodeType.HASHAGGREGATE) != null);
    pn = compileToFragments("SELECT RATIO, count(1) from P1 WHERE NUM < 1 Group by RATIO");
    for (AbstractPlanNode nd : pn) System.out.println("PlanNode Explain string:\n" + nd.toExplainPlanString());
    p = pn.get(0).getChild(0);
    assertTrue(p instanceof AggregatePlanNode);
    p = pn.get(1).getChild(0);
    assertTrue(p instanceof IndexScanPlanNode);
    assertTrue(p.getInlinePlanNode(PlanNodeType.AGGREGATE) != null || p.getInlinePlanNode(PlanNodeType.HASHAGGREGATE) != null);
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode) AggregatePlanNode(org.voltdb.plannodes.AggregatePlanNode) IndexScanPlanNode(org.voltdb.plannodes.IndexScanPlanNode)

Example 32 with AggregatePlanNode

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

the class TestPlansCount method testCountStar22.

// Test counting index feature with partitioned table
public void testCountStar22() {
    List<AbstractPlanNode> pn = compileToFragments("SELECT count(*) from P1 WHERE NUM < ?");
    for (AbstractPlanNode nd : pn) System.out.println("PlanNode Explain string:\n" + nd.toExplainPlanString());
    AbstractPlanNode p = pn.get(0).getChild(0);
    assertTrue(p instanceof AggregatePlanNode);
    p = pn.get(1).getChild(0);
    assertTrue(p instanceof IndexCountPlanNode);
    pn = compileToFragments("SELECT count(1) from P1 WHERE NUM < ?");
    for (AbstractPlanNode nd : pn) System.out.println("PlanNode Explain string:\n" + nd.toExplainPlanString());
    p = pn.get(0).getChild(0);
    assertTrue(p instanceof AggregatePlanNode);
    p = pn.get(1).getChild(0);
    assertTrue(p instanceof IndexCountPlanNode);
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode) IndexCountPlanNode(org.voltdb.plannodes.IndexCountPlanNode) AggregatePlanNode(org.voltdb.plannodes.AggregatePlanNode)

Example 33 with AggregatePlanNode

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

the class TestPlansApproxCountDistinct method assertFragContainsAggWithFunctions.

private void assertFragContainsAggWithFunctions(AbstractPlanNode frag, ExpressionType... expectedAggFns) {
    List<AbstractPlanNode> aggNodes = findAllAggPlanNodes(frag);
    assertFalse("No aggregation node in fragment!", 0 == aggNodes.size());
    assertEquals("More than one aggregation node in fragment!", 1, aggNodes.size());
    AggregatePlanNode aggNode = (AggregatePlanNode) aggNodes.get(0);
    assertAggPlanNodeContainsFunctions(aggNode, expectedAggFns);
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode) AggregatePlanNode(org.voltdb.plannodes.AggregatePlanNode)

Example 34 with AggregatePlanNode

use of org.voltdb.plannodes.AggregatePlanNode 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)

Example 35 with AggregatePlanNode

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

the class TestPlansGroupBy method checkGroupByPartitionKey.

private void checkGroupByPartitionKey(List<AbstractPlanNode> pns, boolean topAgg, boolean having) {
    AbstractPlanNode p;
    AggregatePlanNode aggNode;
    p = pns.get(0).getChild(0);
    if (topAgg) {
        assertTrue(p instanceof AggregatePlanNode);
        if (having) {
            aggNode = (AggregatePlanNode) p;
            assertNotNull(aggNode.getPostPredicate());
        }
        p = p.getChild(0);
    }
    assertTrue(p instanceof ReceivePlanNode);
    p = pns.get(1).getChild(0);
    assertTrue(p instanceof AbstractScanPlanNode);
    PlanNodeType aggType = PlanNodeType.HASHAGGREGATE;
    if (p instanceof IndexScanPlanNode && ((IndexScanPlanNode) p).isForGroupingOnly()) {
        aggType = PlanNodeType.AGGREGATE;
    }
    assertNotNull(p.getInlinePlanNode(aggType));
    if (having && !topAgg) {
        aggNode = (AggregatePlanNode) p.getInlinePlanNode(aggType);
        assertNotNull(aggNode.getPostPredicate());
    }
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode) PlanNodeType(org.voltdb.types.PlanNodeType) AbstractScanPlanNode(org.voltdb.plannodes.AbstractScanPlanNode) 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)

Aggregations

AggregatePlanNode (org.voltdb.plannodes.AggregatePlanNode)38 AbstractPlanNode (org.voltdb.plannodes.AbstractPlanNode)37 HashAggregatePlanNode (org.voltdb.plannodes.HashAggregatePlanNode)22 AbstractScanPlanNode (org.voltdb.plannodes.AbstractScanPlanNode)15 ProjectionPlanNode (org.voltdb.plannodes.ProjectionPlanNode)14 ReceivePlanNode (org.voltdb.plannodes.ReceivePlanNode)10 AbstractReceivePlanNode (org.voltdb.plannodes.AbstractReceivePlanNode)8 OrderByPlanNode (org.voltdb.plannodes.OrderByPlanNode)8 AbstractExpression (org.voltdb.expressions.AbstractExpression)7 IndexScanPlanNode (org.voltdb.plannodes.IndexScanPlanNode)7 LimitPlanNode (org.voltdb.plannodes.LimitPlanNode)7 SendPlanNode (org.voltdb.plannodes.SendPlanNode)6 SeqScanPlanNode (org.voltdb.plannodes.SeqScanPlanNode)6 MergeReceivePlanNode (org.voltdb.plannodes.MergeReceivePlanNode)5 PartialAggregatePlanNode (org.voltdb.plannodes.PartialAggregatePlanNode)5 TableCountPlanNode (org.voltdb.plannodes.TableCountPlanNode)5 AbstractSubqueryExpression (org.voltdb.expressions.AbstractSubqueryExpression)3 IndexCountPlanNode (org.voltdb.plannodes.IndexCountPlanNode)3 NestLoopPlanNode (org.voltdb.plannodes.NestLoopPlanNode)3 ArrayList (java.util.ArrayList)2