use of org.voltdb.plannodes.AbstractScanPlanNode 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.AbstractScanPlanNode 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.AbstractScanPlanNode 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());
}
use of org.voltdb.plannodes.AbstractScanPlanNode in project voltdb by VoltDB.
the class TestPlansInExistsSubQueries method testInToExist.
public void testInToExist() {
AbstractPlanNode pn = compile("select r2.c from r2 where r2.a in (select c from r1)");
pn = pn.getChild(0);
assertTrue(pn instanceof AbstractScanPlanNode);
AbstractScanPlanNode spl = (AbstractScanPlanNode) pn;
// Check param indexes
AbstractExpression e = spl.getPredicate();
assertEquals(ExpressionType.OPERATOR_EXISTS, e.getExpressionType());
AbstractSubqueryExpression subExpr = (AbstractSubqueryExpression) e.getLeft();
assertEquals(1, subExpr.getArgs().size());
assertEquals(1, subExpr.getParameterIdxList().size());
assertEquals(Integer.valueOf(0), subExpr.getParameterIdxList().get(0));
AbstractExpression tve = subExpr.getArgs().get(0);
assertTrue(tve instanceof TupleValueExpression);
assertEquals("R2", ((TupleValueExpression) tve).getTableName());
assertEquals("A", ((TupleValueExpression) tve).getColumnName());
}
use of org.voltdb.plannodes.AbstractScanPlanNode in project voltdb by VoltDB.
the class TestPlansScalarSubQueries method testWhereEqualRow.
public void testWhereEqualRow() {
AbstractPlanNode pn = compile("select r2.c from r2 where (a,c) = (select r1.a, r1.c from r1 where r1.c = r2.c);");
pn = pn.getChild(0);
assertTrue(pn instanceof AbstractScanPlanNode);
AbstractExpression pred = ((AbstractScanPlanNode) pn).getPredicate();
assertEquals(ExpressionType.COMPARE_EQUAL, pred.getExpressionType());
assertEquals(ExpressionType.ROW_SUBQUERY, pred.getLeft().getExpressionType());
assertEquals(ExpressionType.SELECT_SUBQUERY, pred.getRight().getExpressionType());
assertEquals(1, pred.getRight().getArgs().size());
}
Aggregations