use of org.voltdb.plannodes.AbstractScanPlanNode in project voltdb by VoltDB.
the class TestPlansGroupBy method testEdgeComplexRelatedCases.
public void testEdgeComplexRelatedCases() {
List<AbstractPlanNode> pns;
pns = compileToFragments("select PKEY+A1 from T1 Order by PKEY+A1");
AbstractPlanNode p = pns.get(0).getChild(0);
assertTrue(p instanceof ProjectionPlanNode);
assertTrue(p.getChild(0) instanceof OrderByPlanNode);
assertTrue(p.getChild(0).getChild(0) instanceof ReceivePlanNode);
p = pns.get(1).getChild(0);
assertTrue(p instanceof AbstractScanPlanNode);
// Useless order by clause.
pns = compileToFragments("SELECT count(*) FROM P1 order by PKEY");
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);
pns = compileToFragments("SELECT A1, count(*) as tag FROM P1 group by A1 order by tag, A1 limit 1");
p = pns.get(0).getChild(0);
// ENG-5066: now Limit is pushed under Projection
// Limit is also inlined with Orderby node
assertTrue(p instanceof ProjectionPlanNode);
p = p.getChild(0);
assertTrue(p instanceof OrderByPlanNode);
assertNotNull(p.getInlinePlanNode(PlanNodeType.LIMIT));
assertTrue(p.getChild(0) instanceof AggregatePlanNode);
p = pns.get(1).getChild(0);
// inline aggregate
assertTrue(p instanceof AbstractScanPlanNode);
assertNotNull(p.getInlinePlanNode(PlanNodeType.HASHAGGREGATE));
pns = compileToFragments("SELECT F_D1, count(*) as tag FROM RF group by F_D1 order by tag");
p = pns.get(0).getChild(0);
//* enable to debug */ System.out.println("DEBUG: " + p.toExplainPlanString());
assertTrue(p instanceof ProjectionPlanNode);
p = p.getChild(0);
assertTrue(p instanceof OrderByPlanNode);
p = p.getChild(0);
assertTrue(p instanceof IndexScanPlanNode);
assertNotNull(p.getInlinePlanNode(PlanNodeType.AGGREGATE));
pns = compileToFragments("SELECT F_D1, count(*) FROM RF group by F_D1 order by 2");
p = pns.get(0).getChild(0);
//* enable to debug */ System.out.println("DEBUG: " + p.toExplainPlanString());
assertTrue(p instanceof ProjectionPlanNode);
p = p.getChild(0);
assertTrue(p instanceof OrderByPlanNode);
p = p.getChild(0);
assertTrue(p instanceof IndexScanPlanNode);
assertNotNull(p.getInlinePlanNode(PlanNodeType.AGGREGATE));
}
use of org.voltdb.plannodes.AbstractScanPlanNode 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);
}
use of org.voltdb.plannodes.AbstractScanPlanNode in project voltdb by VoltDB.
the class TestPlansInExistsSubQueries method testNotExists.
public void testNotExists() {
AbstractPlanNode pn = compile("select r2.c from r2 where not exists (select c from r1 where r1.c = r2.c)");
pn = pn.getChild(0);
assertTrue(pn instanceof AbstractScanPlanNode);
AbstractScanPlanNode nps = (AbstractScanPlanNode) pn;
AbstractExpression e = nps.getPredicate();
assertEquals(ExpressionType.OPERATOR_NOT, e.getExpressionType());
AbstractExpression le = e.getLeft();
assertEquals(ExpressionType.OPERATOR_EXISTS, le.getExpressionType());
AbstractSubqueryExpression subExpr = (AbstractSubqueryExpression) le.getLeft();
assertEquals(1, subExpr.getArgs().size());
assertEquals(1, subExpr.getParameterIdxList().size());
assertEquals(Integer.valueOf(0), subExpr.getParameterIdxList().get(0));
}
use of org.voltdb.plannodes.AbstractScanPlanNode 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());
}
}
use of org.voltdb.plannodes.AbstractScanPlanNode 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);
}
Aggregations