use of org.voltdb.plannodes.IndexScanPlanNode in project voltdb by VoltDB.
the class TestPlansCount method testCountStar21.
// test with group by with Partitioned table
public void testCountStar21() {
List<AbstractPlanNode> pn = compileToFragments("SELECT RATIO, count(*) from P1 WHERE NUM < 1 Group by RATIO");
for (AbstractPlanNode nd : pn) System.out.println("PlanNode Explain string:\n" + nd.toExplainPlanString());
AbstractPlanNode p = pn.get(0).getChild(0);
assertTrue(p instanceof AggregatePlanNode);
p = pn.get(1).getChild(0);
assertTrue(p instanceof IndexScanPlanNode);
assertTrue(p.getInlinePlanNode(PlanNodeType.AGGREGATE) != null || p.getInlinePlanNode(PlanNodeType.HASHAGGREGATE) != null);
pn = compileToFragments("SELECT RATIO, count(1) from P1 WHERE NUM < 1 Group by RATIO");
for (AbstractPlanNode nd : pn) System.out.println("PlanNode Explain string:\n" + nd.toExplainPlanString());
p = pn.get(0).getChild(0);
assertTrue(p instanceof AggregatePlanNode);
p = pn.get(1).getChild(0);
assertTrue(p instanceof IndexScanPlanNode);
assertTrue(p.getInlinePlanNode(PlanNodeType.AGGREGATE) != null || p.getInlinePlanNode(PlanNodeType.HASHAGGREGATE) != null);
}
use of org.voltdb.plannodes.IndexScanPlanNode 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.IndexScanPlanNode 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.IndexScanPlanNode in project voltdb by VoltDB.
the class TestPlansGroupBy method testCountDistinct.
public void testCountDistinct() {
AbstractPlanNode p;
List<AbstractPlanNode> pns;
// push down distinct because of group by partition column
pns = compileToFragments("SELECT A4, count(distinct B4) FROM T4 GROUP BY A4");
p = pns.get(0).getChild(0);
assertTrue(p instanceof ReceivePlanNode);
p = pns.get(1).getChild(0);
assertTrue(p instanceof AbstractScanPlanNode);
assertNotNull(p.getInlinePlanNode(PlanNodeType.HASHAGGREGATE));
// group by multiple columns
pns = compileToFragments("SELECT C4, A4, count(distinct B4) FROM T4 GROUP BY C4, A4");
p = pns.get(0).getChild(0);
assertTrue(p instanceof ReceivePlanNode);
p = pns.get(1).getChild(0);
assertTrue(p instanceof AbstractScanPlanNode);
assertNotNull(p.getInlinePlanNode(PlanNodeType.HASHAGGREGATE));
// not push down distinct
pns = compileToFragments("SELECT ABS(A4), count(distinct B4) FROM T4 GROUP BY ABS(A4)");
p = pns.get(0).getChild(0);
assertTrue(p instanceof HashAggregatePlanNode);
assertTrue(p.getChild(0) instanceof ReceivePlanNode);
p = pns.get(1).getChild(0);
assertTrue(p instanceof AbstractScanPlanNode);
assertNull(p.getInlinePlanNode(PlanNodeType.HASHAGGREGATE));
// test not group by partition column with index available
pns = compileToFragments("SELECT A.NUM, COUNT(DISTINCT A.ID ) AS Q58 FROM P2 A GROUP BY A.NUM; ");
p = pns.get(0).getChild(0);
assertTrue(p instanceof HashAggregatePlanNode);
assertTrue(p.getChild(0) instanceof ReceivePlanNode);
p = pns.get(1).getChild(0);
assertTrue(p instanceof IndexScanPlanNode);
assertTrue(p.toExplainPlanString().contains("for deterministic order only"));
}
use of org.voltdb.plannodes.IndexScanPlanNode in project voltdb by VoltDB.
the class TestMultipleOuterJoinPlans method verifyIndexScanNode.
private void verifyIndexScanNode(AbstractPlanNode n, IndexLookupType lookupType, ExpressionType predExpressionType) {
assertNotNull(n);
assertEquals(PlanNodeType.INDEXSCAN, n.getPlanNodeType());
IndexScanPlanNode isn = (IndexScanPlanNode) n;
assertEquals(lookupType, isn.getLookupType());
if (predExpressionType != null) {
assertEquals(predExpressionType, isn.getPredicate().getExpressionType());
} else {
assertNull(isn.getPredicate());
}
}
Aggregations