Search in sources :

Example 26 with ReceivePlanNode

use of org.voltdb.plannodes.ReceivePlanNode 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 27 with ReceivePlanNode

use of org.voltdb.plannodes.ReceivePlanNode 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 28 with ReceivePlanNode

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

the class TestMultipleOuterJoinPlans method testMultitableDistributedJoin.

public void testMultitableDistributedJoin() {
    List<AbstractPlanNode> lpn;
    AbstractPlanNode n;
    // One distributed table
    lpn = compileToFragments("select *  FROM R3,R1 LEFT JOIN P2 ON R3.A = P2.A WHERE R3.A=R1.A ");
    assertTrue(lpn.size() == 2);
    n = lpn.get(0).getChild(0).getChild(0);
    verifyJoinNode(n, PlanNodeType.NESTLOOP, JoinType.LEFT, null, ExpressionType.COMPARE_EQUAL, null, PlanNodeType.NESTLOOPINDEX, PlanNodeType.RECEIVE);
    // R3.A and P2.A have an index. P2,R1 is NLIJ/inlined IndexScan because it's an inner join even P2 is distributed
    lpn = compileToFragments("select *  FROM P2,R1 LEFT JOIN R3 ON R3.A = P2.A WHERE P2.A=R1.A ");
    assertTrue(lpn.size() == 2);
    n = lpn.get(0).getChild(0).getChild(0);
    assertTrue(n instanceof ReceivePlanNode);
    n = lpn.get(1).getChild(0);
    verifyJoinNode(n, PlanNodeType.NESTLOOPINDEX, JoinType.LEFT, null, null, null, PlanNodeType.NESTLOOPINDEX, PlanNodeType.INDEXSCAN);
    // R3.A has an index. R3,P2 is NLJ because it's an outer join and P2 is distributed
    lpn = compileToFragments("select *  FROM R3,R1 LEFT JOIN P2 ON R3.A = P2.A WHERE R3.A=R1.A ");
    assertTrue(lpn.size() == 2);
    // to debug */ System.out.println("DEBUG 0.0: " + lpn.get(0).toExplainPlanString());
    // to debug */ System.out.println("DEBUG 0.1: " + lpn.get(1).toExplainPlanString());
    n = lpn.get(0).getChild(0).getChild(0);
    verifyJoinNode(n, PlanNodeType.NESTLOOP, JoinType.LEFT, null, ExpressionType.COMPARE_EQUAL, null, PlanNodeType.NESTLOOPINDEX, PlanNodeType.RECEIVE);
    n = n.getChild(0);
    verifyJoinNode(n, PlanNodeType.NESTLOOPINDEX, JoinType.INNER, null, null, null, PlanNodeType.SEQSCAN, PlanNodeType.INDEXSCAN);
    n = lpn.get(1).getChild(0);
    // For determinism reason
    assertTrue(n instanceof IndexScanPlanNode);
    // R3.A has an index. P2,R1 is NLJ because P2 is distributed and it's an outer join
    lpn = compileToFragments("select *  FROM R1 LEFT JOIN P2 ON R1.A = P2.A, R3 WHERE R1.A=R3.A ");
    assertTrue(lpn.size() == 2);
    // to debug */ System.out.println("DEBUG 1.0: " + lpn.get(0).toExplainPlanString());
    // to debug */ System.out.println("DEBUG 1.1: " + lpn.get(1).toExplainPlanString());
    n = lpn.get(0).getChild(0).getChild(0);
    verifyJoinNode(n, PlanNodeType.NESTLOOPINDEX, JoinType.INNER, null, null, null, PlanNodeType.NESTLOOP, PlanNodeType.SEQSCAN);
    n = n.getChild(0);
    verifyJoinNode(n, PlanNodeType.NESTLOOP, JoinType.LEFT, null, ExpressionType.COMPARE_EQUAL, null, PlanNodeType.SEQSCAN, PlanNodeType.RECEIVE);
    n = lpn.get(1).getChild(0);
    // For determinism reason
    assertTrue(n instanceof IndexScanPlanNode);
    // Two distributed table
    lpn = compileToFragments("select *  FROM R3,P1 LEFT JOIN P2 ON R3.A = P2.A WHERE R3.A=P1.A ");
    assertTrue(lpn.size() == 2);
    n = lpn.get(0).getChild(0).getChild(0);
    assertTrue(n instanceof ReceivePlanNode);
    n = lpn.get(1).getChild(0);
    verifyJoinNode(n, PlanNodeType.NESTLOOPINDEX, JoinType.LEFT, null, null, null, PlanNodeType.NESTLOOPINDEX, PlanNodeType.INDEXSCAN);
    n = n.getChild(0);
    verifyJoinNode(n, PlanNodeType.NESTLOOPINDEX, JoinType.INNER, null, null, null, PlanNodeType.SEQSCAN, PlanNodeType.INDEXSCAN);
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode) IndexScanPlanNode(org.voltdb.plannodes.IndexScanPlanNode) ReceivePlanNode(org.voltdb.plannodes.ReceivePlanNode)

Aggregations

ReceivePlanNode (org.voltdb.plannodes.ReceivePlanNode)28 AbstractPlanNode (org.voltdb.plannodes.AbstractPlanNode)27 HashAggregatePlanNode (org.voltdb.plannodes.HashAggregatePlanNode)17 MergeReceivePlanNode (org.voltdb.plannodes.MergeReceivePlanNode)15 AbstractReceivePlanNode (org.voltdb.plannodes.AbstractReceivePlanNode)14 ProjectionPlanNode (org.voltdb.plannodes.ProjectionPlanNode)13 SendPlanNode (org.voltdb.plannodes.SendPlanNode)12 AggregatePlanNode (org.voltdb.plannodes.AggregatePlanNode)10 AbstractScanPlanNode (org.voltdb.plannodes.AbstractScanPlanNode)8 OrderByPlanNode (org.voltdb.plannodes.OrderByPlanNode)6 IndexScanPlanNode (org.voltdb.plannodes.IndexScanPlanNode)5 NestLoopPlanNode (org.voltdb.plannodes.NestLoopPlanNode)5 NestLoopIndexPlanNode (org.voltdb.plannodes.NestLoopIndexPlanNode)4 SeqScanPlanNode (org.voltdb.plannodes.SeqScanPlanNode)4 AbstractExpression (org.voltdb.expressions.AbstractExpression)2 AbstractJoinPlanNode (org.voltdb.plannodes.AbstractJoinPlanNode)2 PartialAggregatePlanNode (org.voltdb.plannodes.PartialAggregatePlanNode)2 PlanNodeType (org.voltdb.types.PlanNodeType)2 Constraint (org.voltdb.catalog.Constraint)1 AggregateExpression (org.voltdb.expressions.AggregateExpression)1