Search in sources :

Example 46 with ProjectionPlanNode

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

the class TestPlansGroupBy method checkHasComplexAgg.

private void checkHasComplexAgg(List<AbstractPlanNode> pns, boolean projectPushdown) {
    assertTrue(pns.size() > 0);
    boolean isDistributed = pns.size() > 1 ? true : false;
    if (projectPushdown) {
        assertTrue(isDistributed);
    }
    AbstractPlanNode p = pns.get(0).getChild(0);
    if (p instanceof LimitPlanNode) {
        p = p.getChild(0);
    }
    if (p instanceof OrderByPlanNode) {
        p = p.getChild(0);
    }
    if (!projectPushdown) {
        assertTrue(p instanceof ProjectionPlanNode);
    }
    while (p.getChildCount() > 0) {
        p = p.getChild(0);
        assertFalse(p instanceof ProjectionPlanNode);
    }
    if (isDistributed) {
        p = pns.get(1).getChild(0);
        int projectCount = 0;
        while (p.getChildCount() > 0) {
            p = p.getChild(0);
            if (p instanceof ProjectionPlanNode) {
                projectCount++;
                assertTrue(projectPushdown);
            }
        }
        if (projectPushdown) {
            assertEquals(1, projectCount);
        }
    }
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode) OrderByPlanNode(org.voltdb.plannodes.OrderByPlanNode) LimitPlanNode(org.voltdb.plannodes.LimitPlanNode) ProjectionPlanNode(org.voltdb.plannodes.ProjectionPlanNode)

Example 47 with ProjectionPlanNode

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

the class TestPlansGroupBy method testUnOptimizedAVG.

public void testUnOptimizedAVG() {
    List<AbstractPlanNode> pns;
    pns = compileToFragments("SELECT AVG(A1) FROM R1");
    checkOptimizedAgg(pns, false);
    pns = compileToFragments("SELECT A1, AVG(PKEY) FROM R1 GROUP BY A1");
    checkOptimizedAgg(pns, false);
    pns = compileToFragments("SELECT A1, AVG(PKEY)+1 FROM R1 GROUP BY A1");
    checkHasComplexAgg(pns);
    AbstractPlanNode p = pns.get(0).getChild(0);
    assertTrue(p instanceof ProjectionPlanNode);
    p = p.getChild(0);
    assertTrue(p instanceof AbstractScanPlanNode);
    assertTrue(p.getInlinePlanNode(PlanNodeType.AGGREGATE) != null || p.getInlinePlanNode(PlanNodeType.HASHAGGREGATE) != null);
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode) AbstractScanPlanNode(org.voltdb.plannodes.AbstractScanPlanNode) ProjectionPlanNode(org.voltdb.plannodes.ProjectionPlanNode)

Example 48 with ProjectionPlanNode

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

the class TestPlansGroupBy method testComplexAggwithDistinct.

public void testComplexAggwithDistinct() {
    List<AbstractPlanNode> pns;
    pns = compileToFragments("SELECT A1, sum(A1), sum(distinct A1)+11 FROM P1 GROUP BY A1 ORDER BY A1");
    checkHasComplexAgg(pns);
    // Test aggregation node not push down with distinct
    AbstractPlanNode p = pns.get(0).getChild(0);
    assertTrue(p instanceof OrderByPlanNode);
    assertTrue(p.getChild(0) instanceof ProjectionPlanNode);
    assertTrue(p.getChild(0).getChild(0) instanceof AggregatePlanNode);
    p = pns.get(1).getChild(0);
    assertTrue(p instanceof AbstractScanPlanNode);
}
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) ProjectionPlanNode(org.voltdb.plannodes.ProjectionPlanNode)

Example 49 with ProjectionPlanNode

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

the class TestIndexReverseScan method checkForwardScan.

private void checkForwardScan(String indexName, IndexLookupType lookupType, int searchKeys, int endKeys, int predicates, SortDirectionType sortType, boolean needOrderby) {
    AbstractPlanNode pn = compile(sql);
    System.out.println(pn.toExplainPlanString());
    assertTrue(pn instanceof SendPlanNode);
    pn = pn.getChild(0);
    if (needOrderby) {
        assertTrue(pn instanceof ProjectionPlanNode);
        pn = pn.getChild(0);
        assertTrue(pn instanceof OrderByPlanNode);
        pn = pn.getChild(0);
    }
    assertTrue(pn instanceof IndexScanPlanNode);
    IndexScanPlanNode ispn = (IndexScanPlanNode) pn;
    assertTrue(ispn.getTargetIndexName().contains(indexName));
    assertEquals(lookupType, ispn.getLookupType());
    assertEquals(searchKeys, ispn.getSearchKeyExpressions().size());
    assertEquals(endKeys, ExpressionUtil.uncombinePredicate(ispn.getEndExpression()).size());
    assertEquals(predicates, ExpressionUtil.uncombinePredicate(ispn.getPredicate()).size());
    assertEquals(0, ExpressionUtil.uncombinePredicate(ispn.getInitialExpression()).size());
    assertEquals(sortType, ispn.getSortDirection());
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode) OrderByPlanNode(org.voltdb.plannodes.OrderByPlanNode) SendPlanNode(org.voltdb.plannodes.SendPlanNode) IndexScanPlanNode(org.voltdb.plannodes.IndexScanPlanNode) ProjectionPlanNode(org.voltdb.plannodes.ProjectionPlanNode)

Example 50 with ProjectionPlanNode

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

the class TestIndexReverseScan method checkReverseScan.

private void checkReverseScan(String indexName, IndexLookupType lookupType, int searchKeys, int endKeys, int predicates, int initials, boolean artificial, SortDirectionType sortType, boolean needOrderby) {
    AbstractPlanNode pn = compile(sql);
    System.out.println(pn.toExplainPlanString());
    assertTrue(pn instanceof SendPlanNode);
    pn = pn.getChild(0);
    if (needOrderby) {
        assertTrue(pn instanceof ProjectionPlanNode);
        pn = pn.getChild(0);
        assertTrue(pn instanceof OrderByPlanNode);
        pn = pn.getChild(0);
    }
    assertTrue(pn instanceof IndexScanPlanNode);
    IndexScanPlanNode ispn = (IndexScanPlanNode) pn;
    assertTrue(ispn.getTargetIndexName().contains(indexName));
    assertEquals(lookupType, ispn.getLookupType());
    assertEquals(searchKeys, ispn.getSearchKeyExpressions().size());
    assertEquals(endKeys, ExpressionUtil.uncombinePredicate(ispn.getEndExpression()).size());
    assertEquals(predicates, ExpressionUtil.uncombinePredicate(ispn.getPredicate()).size());
    assertEquals(initials, ExpressionUtil.uncombinePredicate(ispn.getInitialExpression()).size());
    // Test artificial post predicate
    if (predicates == 1 && artificial) {
        assertTrue(ispn.getPredicate().getExpressionType() == ExpressionType.OPERATOR_NOT);
        assertTrue(ispn.getPredicate().getLeft().getExpressionType() == ExpressionType.OPERATOR_IS_NULL);
    } else if (predicates > 1) {
        assertTrue(ispn.getPredicate().getExpressionType() == ExpressionType.CONJUNCTION_AND);
    }
    // SortDirection can be INVALID because we use LookupType to determine
    // index scan direction instead in EE.
    assertEquals(sortType, ispn.getSortDirection());
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode) OrderByPlanNode(org.voltdb.plannodes.OrderByPlanNode) SendPlanNode(org.voltdb.plannodes.SendPlanNode) IndexScanPlanNode(org.voltdb.plannodes.IndexScanPlanNode) 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