use of org.voltdb.plannodes.ProjectionPlanNode in project voltdb by VoltDB.
the class TestPlansGroupBy method checkHasComplexAgg.
private void checkHasComplexAgg(List<AbstractPlanNode> pns, boolean projectPushdown) {
assertTrue(pns.size() > 0);
boolean isDistributed = pns.size() > 1 ? true : false;
if (projectPushdown) {
assertTrue(isDistributed);
}
AbstractPlanNode p = pns.get(0).getChild(0);
if (p instanceof LimitPlanNode) {
p = p.getChild(0);
}
if (p instanceof OrderByPlanNode) {
p = p.getChild(0);
}
if (!projectPushdown) {
assertTrue(p instanceof ProjectionPlanNode);
}
while (p.getChildCount() > 0) {
p = p.getChild(0);
assertFalse(p instanceof ProjectionPlanNode);
}
if (isDistributed) {
p = pns.get(1).getChild(0);
int projectCount = 0;
while (p.getChildCount() > 0) {
p = p.getChild(0);
if (p instanceof ProjectionPlanNode) {
projectCount++;
assertTrue(projectPushdown);
}
}
if (projectPushdown) {
assertEquals(1, projectCount);
}
}
}
use of org.voltdb.plannodes.ProjectionPlanNode 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.ProjectionPlanNode 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);
}
use of org.voltdb.plannodes.ProjectionPlanNode in project voltdb by VoltDB.
the class TestIndexReverseScan method checkForwardScan.
private void checkForwardScan(String indexName, IndexLookupType lookupType, int searchKeys, int endKeys, int predicates, SortDirectionType sortType, boolean needOrderby) {
AbstractPlanNode pn = compile(sql);
System.out.println(pn.toExplainPlanString());
assertTrue(pn instanceof SendPlanNode);
pn = pn.getChild(0);
if (needOrderby) {
assertTrue(pn instanceof ProjectionPlanNode);
pn = pn.getChild(0);
assertTrue(pn instanceof OrderByPlanNode);
pn = pn.getChild(0);
}
assertTrue(pn instanceof IndexScanPlanNode);
IndexScanPlanNode ispn = (IndexScanPlanNode) pn;
assertTrue(ispn.getTargetIndexName().contains(indexName));
assertEquals(lookupType, ispn.getLookupType());
assertEquals(searchKeys, ispn.getSearchKeyExpressions().size());
assertEquals(endKeys, ExpressionUtil.uncombinePredicate(ispn.getEndExpression()).size());
assertEquals(predicates, ExpressionUtil.uncombinePredicate(ispn.getPredicate()).size());
assertEquals(0, ExpressionUtil.uncombinePredicate(ispn.getInitialExpression()).size());
assertEquals(sortType, ispn.getSortDirection());
}
use of org.voltdb.plannodes.ProjectionPlanNode in project voltdb by VoltDB.
the class TestIndexReverseScan method checkReverseScan.
private void checkReverseScan(String indexName, IndexLookupType lookupType, int searchKeys, int endKeys, int predicates, int initials, boolean artificial, SortDirectionType sortType, boolean needOrderby) {
AbstractPlanNode pn = compile(sql);
System.out.println(pn.toExplainPlanString());
assertTrue(pn instanceof SendPlanNode);
pn = pn.getChild(0);
if (needOrderby) {
assertTrue(pn instanceof ProjectionPlanNode);
pn = pn.getChild(0);
assertTrue(pn instanceof OrderByPlanNode);
pn = pn.getChild(0);
}
assertTrue(pn instanceof IndexScanPlanNode);
IndexScanPlanNode ispn = (IndexScanPlanNode) pn;
assertTrue(ispn.getTargetIndexName().contains(indexName));
assertEquals(lookupType, ispn.getLookupType());
assertEquals(searchKeys, ispn.getSearchKeyExpressions().size());
assertEquals(endKeys, ExpressionUtil.uncombinePredicate(ispn.getEndExpression()).size());
assertEquals(predicates, ExpressionUtil.uncombinePredicate(ispn.getPredicate()).size());
assertEquals(initials, ExpressionUtil.uncombinePredicate(ispn.getInitialExpression()).size());
// Test artificial post predicate
if (predicates == 1 && artificial) {
assertTrue(ispn.getPredicate().getExpressionType() == ExpressionType.OPERATOR_NOT);
assertTrue(ispn.getPredicate().getLeft().getExpressionType() == ExpressionType.OPERATOR_IS_NULL);
} else if (predicates > 1) {
assertTrue(ispn.getPredicate().getExpressionType() == ExpressionType.CONJUNCTION_AND);
}
// SortDirection can be INVALID because we use LookupType to determine
// index scan direction instead in EE.
assertEquals(sortType, ispn.getSortDirection());
}
Aggregations