Search in sources :

Example 46 with IndexScanPlanNode

use of org.voltdb.plannodes.IndexScanPlanNode 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 47 with IndexScanPlanNode

use of org.voltdb.plannodes.IndexScanPlanNode 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 48 with IndexScanPlanNode

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

Example 49 with IndexScanPlanNode

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

the class TestPlansGroupBy method testCountDistinct.

public void testCountDistinct() {
    AbstractPlanNode p;
    List<AbstractPlanNode> pns;
    // push down distinct because of group by partition column
    pns = compileToFragments("SELECT A4, count(distinct B4) FROM T4 GROUP BY A4");
    p = pns.get(0).getChild(0);
    assertTrue(p instanceof ReceivePlanNode);
    p = pns.get(1).getChild(0);
    assertTrue(p instanceof AbstractScanPlanNode);
    assertNotNull(p.getInlinePlanNode(PlanNodeType.HASHAGGREGATE));
    // group by multiple columns
    pns = compileToFragments("SELECT C4, A4, count(distinct B4) FROM T4 GROUP BY C4, A4");
    p = pns.get(0).getChild(0);
    assertTrue(p instanceof ReceivePlanNode);
    p = pns.get(1).getChild(0);
    assertTrue(p instanceof AbstractScanPlanNode);
    assertNotNull(p.getInlinePlanNode(PlanNodeType.HASHAGGREGATE));
    // not push down distinct
    pns = compileToFragments("SELECT ABS(A4), count(distinct B4) FROM T4 GROUP BY ABS(A4)");
    p = pns.get(0).getChild(0);
    assertTrue(p instanceof HashAggregatePlanNode);
    assertTrue(p.getChild(0) instanceof ReceivePlanNode);
    p = pns.get(1).getChild(0);
    assertTrue(p instanceof AbstractScanPlanNode);
    assertNull(p.getInlinePlanNode(PlanNodeType.HASHAGGREGATE));
    // test not group by partition column with index available
    pns = compileToFragments("SELECT A.NUM, COUNT(DISTINCT A.ID ) AS Q58 FROM P2 A GROUP BY A.NUM; ");
    p = pns.get(0).getChild(0);
    assertTrue(p instanceof HashAggregatePlanNode);
    assertTrue(p.getChild(0) instanceof ReceivePlanNode);
    p = pns.get(1).getChild(0);
    assertTrue(p instanceof IndexScanPlanNode);
    assertTrue(p.toExplainPlanString().contains("for deterministic order only"));
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode) AbstractScanPlanNode(org.voltdb.plannodes.AbstractScanPlanNode) IndexScanPlanNode(org.voltdb.plannodes.IndexScanPlanNode) ReceivePlanNode(org.voltdb.plannodes.ReceivePlanNode) AbstractReceivePlanNode(org.voltdb.plannodes.AbstractReceivePlanNode) HashAggregatePlanNode(org.voltdb.plannodes.HashAggregatePlanNode)

Example 50 with IndexScanPlanNode

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

the class TestMultipleOuterJoinPlans method verifyIndexScanNode.

private void verifyIndexScanNode(AbstractPlanNode n, IndexLookupType lookupType, ExpressionType predExpressionType) {
    assertNotNull(n);
    assertEquals(PlanNodeType.INDEXSCAN, n.getPlanNodeType());
    IndexScanPlanNode isn = (IndexScanPlanNode) n;
    assertEquals(lookupType, isn.getLookupType());
    if (predExpressionType != null) {
        assertEquals(predExpressionType, isn.getPredicate().getExpressionType());
    } else {
        assertNull(isn.getPredicate());
    }
}
Also used : IndexScanPlanNode(org.voltdb.plannodes.IndexScanPlanNode)

Aggregations

IndexScanPlanNode (org.voltdb.plannodes.IndexScanPlanNode)60 AbstractPlanNode (org.voltdb.plannodes.AbstractPlanNode)48 AbstractExpression (org.voltdb.expressions.AbstractExpression)22 NestLoopIndexPlanNode (org.voltdb.plannodes.NestLoopIndexPlanNode)15 SeqScanPlanNode (org.voltdb.plannodes.SeqScanPlanNode)14 NestLoopPlanNode (org.voltdb.plannodes.NestLoopPlanNode)11 ProjectionPlanNode (org.voltdb.plannodes.ProjectionPlanNode)8 AggregatePlanNode (org.voltdb.plannodes.AggregatePlanNode)7 OrderByPlanNode (org.voltdb.plannodes.OrderByPlanNode)6 ArrayList (java.util.ArrayList)5 Index (org.voltdb.catalog.Index)5 ReceivePlanNode (org.voltdb.plannodes.ReceivePlanNode)5 AbstractReceivePlanNode (org.voltdb.plannodes.AbstractReceivePlanNode)4 AbstractScanPlanNode (org.voltdb.plannodes.AbstractScanPlanNode)4 HashAggregatePlanNode (org.voltdb.plannodes.HashAggregatePlanNode)4 SendPlanNode (org.voltdb.plannodes.SendPlanNode)4 TupleValueExpression (org.voltdb.expressions.TupleValueExpression)3 IndexCountPlanNode (org.voltdb.plannodes.IndexCountPlanNode)3 StmtTableScan (org.voltdb.planner.parseinfo.StmtTableScan)2 AbstractJoinPlanNode (org.voltdb.plannodes.AbstractJoinPlanNode)2