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));
}
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());
}
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));
}
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));
}
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());
}
Aggregations