Search in sources :

Example 76 with AbstractPlanNode

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

the class TestPlansGroupBy method checkSimpleTableInlineAgg.

private void checkSimpleTableInlineAgg(String sql) {
    AbstractPlanNode p;
    List<AbstractPlanNode> pns;
    pns = compileToFragments(sql);
    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);
    assertNotNull(p.getInlinePlanNode(PlanNodeType.PROJECTION));
    assertNotNull(p.getInlinePlanNode(PlanNodeType.AGGREGATE));
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode) AbstractScanPlanNode(org.voltdb.plannodes.AbstractScanPlanNode) HashAggregatePlanNode(org.voltdb.plannodes.HashAggregatePlanNode) AggregatePlanNode(org.voltdb.plannodes.AggregatePlanNode) ReceivePlanNode(org.voltdb.plannodes.ReceivePlanNode) AbstractReceivePlanNode(org.voltdb.plannodes.AbstractReceivePlanNode)

Example 77 with AbstractPlanNode

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

the class TestPlansGroupBy method checkMVReaggregateFeatureMergeReceive.

// topNode, reAggNode
private void checkMVReaggregateFeatureMergeReceive(List<AbstractPlanNode> pns, boolean needFix, int numGroupByOfReaggNode, int numAggsOfReaggNode, boolean aggPushdown, boolean aggInline, SortDirectionType sortDirection) {
    assertEquals(2, pns.size());
    AbstractPlanNode p = pns.get(0);
    assertTrue(p instanceof SendPlanNode);
    p = p.getChild(0);
    if (p instanceof ProjectionPlanNode) {
        p = p.getChild(0);
    }
    AbstractPlanNode receiveNode = p;
    assertNotNull(receiveNode);
    AggregatePlanNode reAggNode = AggregatePlanNode.getInlineAggregationNode(receiveNode);
    if (needFix) {
        assertNotNull(reAggNode);
        assertEquals(numGroupByOfReaggNode, reAggNode.getGroupByExpressionsSize());
        assertEquals(numAggsOfReaggNode, reAggNode.getAggregateTypesSize());
    } else {
        assertNull(reAggNode);
    }
    p = pns.get(1);
    assertTrue(p instanceof SendPlanNode);
    p = p.getChild(0);
    assertTrue(p instanceof IndexScanPlanNode);
    assertEquals(sortDirection, ((IndexScanPlanNode) p).getSortDirection());
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode) HashAggregatePlanNode(org.voltdb.plannodes.HashAggregatePlanNode) AggregatePlanNode(org.voltdb.plannodes.AggregatePlanNode) SendPlanNode(org.voltdb.plannodes.SendPlanNode) IndexScanPlanNode(org.voltdb.plannodes.IndexScanPlanNode) ProjectionPlanNode(org.voltdb.plannodes.ProjectionPlanNode)

Example 78 with AbstractPlanNode

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

the class TestPlansGroupBy method testComplexAggwithLimit.

public void testComplexAggwithLimit() {
    List<AbstractPlanNode> pns;
    pns = compileToFragments("SELECT A1, sum(A1), sum(A1)+11 FROM P1 GROUP BY A1 ORDER BY A1 LIMIT 2");
    checkHasComplexAgg(pns);
    // Test limit is not pushed down
    AbstractPlanNode p = pns.get(0).getChild(0);
    assertTrue(p instanceof OrderByPlanNode);
    assertNotNull(p.getInlinePlanNode(PlanNodeType.LIMIT));
    assertTrue(p.getChild(0) instanceof ProjectionPlanNode);
    assertTrue(p.getChild(0).getChild(0) instanceof AggregatePlanNode);
    p = pns.get(1).getChild(0);
    // inline limit with order by
    assertTrue(p instanceof OrderByPlanNode);
    assertNotNull(p.getInlinePlanNode(PlanNodeType.LIMIT));
    p = p.getChild(0);
    // inline aggregate
    assertTrue(p instanceof AbstractScanPlanNode);
    assertNotNull(p.getInlinePlanNode(PlanNodeType.HASHAGGREGATE));
}
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 79 with AbstractPlanNode

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

the class TestPlansInExistsSubQueries method testInHaving.

public void testInHaving() {
    String sql;
    AbstractPlanNode pn;
    AggregatePlanNode aggNode;
    sql = "select a from r1 group by a having max(c) in (select c from r2 )";
    failToCompile(sql, HavingErrorMsg);
    // ENG-8306: Uncomment next block when HAVING with subquery is supported
    //            AbstractPlanNode pn = compile(sql);
    //            pn = pn.getChild(0);
    //            assertTrue(pn instanceof ProjectionPlanNode);
    //            pn = pn.getChild(0);
    //            assertTrue(pn instanceof SeqScanPlanNode);
    //            AggregatePlanNode aggNode = AggregatePlanNode.getInlineAggregationNode(pn);
    //            assertNotNull(aggNode);
    //            NodeSchema ns = aggNode.getOutputSchema();
    //            assertEquals(2, ns.size());
    //            SchemaColumn aggColumn = ns.getColumns().get(1);
    //            assertEquals("$$_MAX_$$_1", aggColumn.getColumnAlias());
    //            AbstractExpression having = aggNode.getPostPredicate();
    //            assertEquals(ExpressionType.OPERATOR_EXISTS, having.getExpressionType());
    //            AbstractExpression se = having.getLeft();
    //            assertEquals(1, se.getArgs().size());
    //            assertTrue(se.getArgs().get(0) instanceof TupleValueExpression);
    //            TupleValueExpression argTve = (TupleValueExpression) se.getArgs().get(0);
    //            assertEquals(1, argTve.getColumnIndex());
    //            assertEquals("$$_MAX_$$_1", argTve.getColumnAlias());
    // HAVING expression evaluates to TRUE and dropped
    sql = "select a from r1 " + " group by a " + " having exists (select max(a) from r2) or max(c) > 0";
    pn = compile(sql);
    pn = pn.getChild(0);
    assertTrue(pn instanceof SeqScanPlanNode);
    aggNode = AggregatePlanNode.getInlineAggregationNode(pn);
    assertNotNull(aggNode);
    assertTrue(aggNode.getPostPredicate() == null);
    // HAVING expression evaluates to FALSE and retained
    sql = "select a from r1 " + " group by a " + " having exists (select max(a) from r2 limit 0) and max(c) > 0";
    pn = compile(sql);
    pn = pn.getChild(0);
    assertTrue(pn instanceof ProjectionPlanNode);
    pn = pn.getChild(0);
    assertTrue(pn instanceof SeqScanPlanNode);
    aggNode = AggregatePlanNode.getInlineAggregationNode(pn);
    assertNotNull(aggNode);
    AbstractExpression having = aggNode.getPostPredicate();
    assertTrue(ConstantValueExpression.isBooleanFalse(having));
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode) SeqScanPlanNode(org.voltdb.plannodes.SeqScanPlanNode) AbstractExpression(org.voltdb.expressions.AbstractExpression) AggregatePlanNode(org.voltdb.plannodes.AggregatePlanNode) ProjectionPlanNode(org.voltdb.plannodes.ProjectionPlanNode)

Example 80 with AbstractPlanNode

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

the class TestPlansInExistsSubQueries method testInAggregated.

public void testInAggregated() {
    AbstractPlanNode pn = compile("select a, sum(c) as sc1 from r1 where (a, c) in " + "( SELECT a, count(c) as sc2 " + "from  r1  GROUP BY a ORDER BY a DESC) GROUP BY A;");
    pn = pn.getChild(0);
    assertTrue(pn instanceof AbstractScanPlanNode);
    AbstractExpression e = ((AbstractScanPlanNode) pn).getPredicate();
    assertEquals(ExpressionType.OPERATOR_EXISTS, e.getExpressionType());
    AbstractSubqueryExpression subExpr = (AbstractSubqueryExpression) e.getLeft();
    AbstractPlanNode sn = subExpr.getSubqueryNode();
    // Added LIMIT 1
    assertTrue(sn instanceof LimitPlanNode);
    assertEquals(1, ((LimitPlanNode) sn).getLimit());
    sn = sn.getChild(0);
    assertTrue(sn instanceof SeqScanPlanNode);
    AggregatePlanNode aggNode = AggregatePlanNode.getInlineAggregationNode(sn);
    assertNotNull(aggNode.getPostPredicate());
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode) SeqScanPlanNode(org.voltdb.plannodes.SeqScanPlanNode) AbstractScanPlanNode(org.voltdb.plannodes.AbstractScanPlanNode) AbstractExpression(org.voltdb.expressions.AbstractExpression) AggregatePlanNode(org.voltdb.plannodes.AggregatePlanNode) AbstractSubqueryExpression(org.voltdb.expressions.AbstractSubqueryExpression) LimitPlanNode(org.voltdb.plannodes.LimitPlanNode)

Aggregations

AbstractPlanNode (org.voltdb.plannodes.AbstractPlanNode)259 AbstractExpression (org.voltdb.expressions.AbstractExpression)55 IndexScanPlanNode (org.voltdb.plannodes.IndexScanPlanNode)48 ProjectionPlanNode (org.voltdb.plannodes.ProjectionPlanNode)48 AbstractScanPlanNode (org.voltdb.plannodes.AbstractScanPlanNode)46 SeqScanPlanNode (org.voltdb.plannodes.SeqScanPlanNode)44 AggregatePlanNode (org.voltdb.plannodes.AggregatePlanNode)37 NestLoopPlanNode (org.voltdb.plannodes.NestLoopPlanNode)37 HashAggregatePlanNode (org.voltdb.plannodes.HashAggregatePlanNode)29 OrderByPlanNode (org.voltdb.plannodes.OrderByPlanNode)29 ReceivePlanNode (org.voltdb.plannodes.ReceivePlanNode)27 SendPlanNode (org.voltdb.plannodes.SendPlanNode)27 MergeReceivePlanNode (org.voltdb.plannodes.MergeReceivePlanNode)20 AbstractReceivePlanNode (org.voltdb.plannodes.AbstractReceivePlanNode)16 NestLoopIndexPlanNode (org.voltdb.plannodes.NestLoopIndexPlanNode)16 SchemaColumn (org.voltdb.plannodes.SchemaColumn)15 NodeSchema (org.voltdb.plannodes.NodeSchema)14 UnionPlanNode (org.voltdb.plannodes.UnionPlanNode)14 LimitPlanNode (org.voltdb.plannodes.LimitPlanNode)12 PlanNodeType (org.voltdb.types.PlanNodeType)12