use of org.voltdb.plannodes.ReceivePlanNode 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.ReceivePlanNode 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.ReceivePlanNode in project voltdb by VoltDB.
the class TestMultipleOuterJoinPlans method testMultitableDistributedJoin.
public void testMultitableDistributedJoin() {
List<AbstractPlanNode> lpn;
AbstractPlanNode n;
// One distributed table
lpn = compileToFragments("select * FROM R3,R1 LEFT JOIN P2 ON R3.A = P2.A WHERE R3.A=R1.A ");
assertTrue(lpn.size() == 2);
n = lpn.get(0).getChild(0).getChild(0);
verifyJoinNode(n, PlanNodeType.NESTLOOP, JoinType.LEFT, null, ExpressionType.COMPARE_EQUAL, null, PlanNodeType.NESTLOOPINDEX, PlanNodeType.RECEIVE);
// R3.A and P2.A have an index. P2,R1 is NLIJ/inlined IndexScan because it's an inner join even P2 is distributed
lpn = compileToFragments("select * FROM P2,R1 LEFT JOIN R3 ON R3.A = P2.A WHERE P2.A=R1.A ");
assertTrue(lpn.size() == 2);
n = lpn.get(0).getChild(0).getChild(0);
assertTrue(n instanceof ReceivePlanNode);
n = lpn.get(1).getChild(0);
verifyJoinNode(n, PlanNodeType.NESTLOOPINDEX, JoinType.LEFT, null, null, null, PlanNodeType.NESTLOOPINDEX, PlanNodeType.INDEXSCAN);
// R3.A has an index. R3,P2 is NLJ because it's an outer join and P2 is distributed
lpn = compileToFragments("select * FROM R3,R1 LEFT JOIN P2 ON R3.A = P2.A WHERE R3.A=R1.A ");
assertTrue(lpn.size() == 2);
// to debug */ System.out.println("DEBUG 0.0: " + lpn.get(0).toExplainPlanString());
// to debug */ System.out.println("DEBUG 0.1: " + lpn.get(1).toExplainPlanString());
n = lpn.get(0).getChild(0).getChild(0);
verifyJoinNode(n, PlanNodeType.NESTLOOP, JoinType.LEFT, null, ExpressionType.COMPARE_EQUAL, null, PlanNodeType.NESTLOOPINDEX, PlanNodeType.RECEIVE);
n = n.getChild(0);
verifyJoinNode(n, PlanNodeType.NESTLOOPINDEX, JoinType.INNER, null, null, null, PlanNodeType.SEQSCAN, PlanNodeType.INDEXSCAN);
n = lpn.get(1).getChild(0);
// For determinism reason
assertTrue(n instanceof IndexScanPlanNode);
// R3.A has an index. P2,R1 is NLJ because P2 is distributed and it's an outer join
lpn = compileToFragments("select * FROM R1 LEFT JOIN P2 ON R1.A = P2.A, R3 WHERE R1.A=R3.A ");
assertTrue(lpn.size() == 2);
// to debug */ System.out.println("DEBUG 1.0: " + lpn.get(0).toExplainPlanString());
// to debug */ System.out.println("DEBUG 1.1: " + lpn.get(1).toExplainPlanString());
n = lpn.get(0).getChild(0).getChild(0);
verifyJoinNode(n, PlanNodeType.NESTLOOPINDEX, JoinType.INNER, null, null, null, PlanNodeType.NESTLOOP, PlanNodeType.SEQSCAN);
n = n.getChild(0);
verifyJoinNode(n, PlanNodeType.NESTLOOP, JoinType.LEFT, null, ExpressionType.COMPARE_EQUAL, null, PlanNodeType.SEQSCAN, PlanNodeType.RECEIVE);
n = lpn.get(1).getChild(0);
// For determinism reason
assertTrue(n instanceof IndexScanPlanNode);
// Two distributed table
lpn = compileToFragments("select * FROM R3,P1 LEFT JOIN P2 ON R3.A = P2.A WHERE R3.A=P1.A ");
assertTrue(lpn.size() == 2);
n = lpn.get(0).getChild(0).getChild(0);
assertTrue(n instanceof ReceivePlanNode);
n = lpn.get(1).getChild(0);
verifyJoinNode(n, PlanNodeType.NESTLOOPINDEX, JoinType.LEFT, null, null, null, PlanNodeType.NESTLOOPINDEX, PlanNodeType.INDEXSCAN);
n = n.getChild(0);
verifyJoinNode(n, PlanNodeType.NESTLOOPINDEX, JoinType.INNER, null, null, null, PlanNodeType.SEQSCAN, PlanNodeType.INDEXSCAN);
}
Aggregations