use of org.voltdb.plannodes.ReceivePlanNode in project voltdb by VoltDB.
the class TestPlansSubQueries method testTableAggSubquery.
public void testTableAggSubquery() {
AbstractPlanNode pn;
List<AbstractPlanNode> planNodes;
AbstractPlanNode nlpn;
planNodes = compileToFragments("SELECT * FROM (SELECT sum(C) AS SC FROM P1) T1");
assertEquals(2, planNodes.size());
pn = planNodes.get(0).getChild(0);
checkSeqScan(pn, "T1", "SC");
assertNotNull(pn.getInlinePlanNode(PlanNodeType.PROJECTION));
pn = pn.getChild(0);
assertTrue(pn instanceof AggregatePlanNode);
pn = pn.getChild(0);
assertTrue(pn instanceof ReceivePlanNode);
pn = planNodes.get(1);
assertTrue(pn instanceof SendPlanNode);
pn = pn.getChild(0);
checkSeqScan(pn, "P1");
assertNotNull(pn.getInlinePlanNode(PlanNodeType.PROJECTION));
assertNotNull(pn.getInlinePlanNode(PlanNodeType.AGGREGATE));
failToCompile("SELECT * FROM (SELECT sum(C) AS SC FROM P1) T1, P2 " + "where P2.A = T1.SC", joinErrorMsg);
failToCompile("SELECT * FROM (SELECT count(A) as A FROM P1) T1, P2 " + "where P2.A = T1.A", joinErrorMsg);
// Special non-push-down-able join case where the join must follow the
// agg which must follow the send/receive.
planNodes = compileToFragments("SELECT * FROM (SELECT sum(C) AS SC FROM P1) T1, R1 " + "where R1.A = T1.SC");
assertEquals(2, planNodes.size());
//* enable to debug */ System.out.println(planNodes.get(0).toExplainPlanString());
//* enable to debug */ System.out.println(planNodes.get(1).toExplainPlanString());
pn = planNodes.get(0).getChild(0);
assertTrue(pn instanceof ProjectionPlanNode);
nlpn = pn.getChild(0);
assertTrue(nlpn instanceof NestLoopPlanNode);
assertEquals(JoinType.INNER, ((NestLoopPlanNode) nlpn).getJoinType());
pn = nlpn.getChild(1);
checkSeqScan(pn, "R1");
pn = nlpn.getChild(0);
checkSeqScan(pn, "T1");
assertNotNull(pn.getInlinePlanNode(PlanNodeType.PROJECTION));
pn = pn.getChild(0);
assertTrue(pn instanceof AggregatePlanNode);
pn = pn.getChild(0);
assertTrue(pn instanceof ReceivePlanNode);
pn = planNodes.get(1).getChild(0);
checkPrimaryKeyIndexScan(pn, "P1");
assertNotNull(pn.getInlinePlanNode(PlanNodeType.PROJECTION));
assertNotNull(pn.getInlinePlanNode(PlanNodeType.AGGREGATE));
}
use of org.voltdb.plannodes.ReceivePlanNode in project voltdb by VoltDB.
the class SubPlanAssembler method addSendReceivePair.
/**
* Insert a send receive pair above the supplied scanNode.
* @param scanNode that needs to be distributed
* @return return the newly created receive node (which is linked to the new sends)
*/
protected static AbstractPlanNode addSendReceivePair(AbstractPlanNode scanNode) {
SendPlanNode sendNode = new SendPlanNode();
sendNode.addAndLinkChild(scanNode);
ReceivePlanNode recvNode = new ReceivePlanNode();
recvNode.addAndLinkChild(sendNode);
return recvNode;
}
use of org.voltdb.plannodes.ReceivePlanNode in project voltdb by VoltDB.
the class TestPlansDML method testBasicUpdateAndDelete.
public void testBasicUpdateAndDelete() {
// select * with ON clause should return all columns from all tables
List<AbstractPlanNode> pns;
AbstractPlanNode pn;
AbstractPlanNode node;
pns = compileToFragments("UPDATE R1 SET C = 1 WHERE C = 0");
pn = pns.get(0);
System.out.println(pn.toExplainPlanString());
node = pn.getChild(0).getChild(0);
assertTrue(node instanceof ReceivePlanNode);
pn = pns.get(1);
node = pn.getChild(0);
assertTrue(node instanceof UpdatePlanNode);
pns = compileToFragments("DELETE FROM R1 WHERE C = 0");
pn = pns.get(0);
System.out.println(pn.toExplainPlanString());
node = pn.getChild(0).getChild(0);
assertTrue(node instanceof ReceivePlanNode);
pn = pns.get(1);
node = pn.getChild(0);
assertTrue(node instanceof DeletePlanNode);
pns = compileToFragments("INSERT INTO R1 VALUES (1, 2, 3)");
pn = pns.get(0);
System.out.println(pn.toExplainPlanString());
node = pn.getChild(0).getChild(0);
assertTrue(node instanceof ReceivePlanNode);
pn = pns.get(1);
node = pn.getChild(0);
assertTrue(node instanceof InsertPlanNode);
pns = compileToFragments("UPDATE P1 SET C = 1 WHERE C = 0");
pn = pns.get(0);
System.out.println(pn.toExplainPlanString());
node = pn.getChild(0).getChild(0);
assertTrue(node instanceof ReceivePlanNode);
pn = pns.get(1);
node = pn.getChild(0);
assertTrue(node instanceof UpdatePlanNode);
pns = compileToFragments("DELETE FROM P1 WHERE C = 0");
pn = pns.get(0);
System.out.println(pn.toExplainPlanString());
node = pn.getChild(0).getChild(0);
assertTrue(node instanceof ReceivePlanNode);
pn = pns.get(1);
node = pn.getChild(0);
assertTrue(node instanceof DeletePlanNode);
pns = compileToFragments("UPDATE P1 SET C = 1 WHERE A = 0");
pn = pns.get(0);
System.out.println(pn.toExplainPlanString());
//n = pn.getChild(0);
assertTrue(pn instanceof UpdatePlanNode);
pns = compileToFragments("DELETE FROM P1 WHERE A = 0");
pn = pns.get(0);
System.out.println(pn.toExplainPlanString());
//n = pn.getChild(0);
assertTrue(pn instanceof DeletePlanNode);
pns = compileToFragments("INSERT INTO P1 VALUES (1, 2)");
pn = pns.get(0);
System.out.println(pn.toExplainPlanString());
//n = pn.getChild(0).getChild(0);
assertTrue(pn instanceof InsertPlanNode);
}
use of org.voltdb.plannodes.ReceivePlanNode 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.ReceivePlanNode in project voltdb by VoltDB.
the class TestPlansGroupBy method checkMVFixWithWhere.
private void checkMVFixWithWhere(List<AbstractPlanNode> pns, Object aggFilters, Object scanFilters) {
AbstractPlanNode p = pns.get(0);
List<AbstractPlanNode> nodes = p.findAllNodesOfClass(AbstractReceivePlanNode.class);
assertEquals(1, nodes.size());
p = nodes.get(0);
// Find re-aggregation node.
assertTrue(p instanceof ReceivePlanNode);
assertTrue(p.getParent(0) instanceof HashAggregatePlanNode);
HashAggregatePlanNode reAggNode = (HashAggregatePlanNode) p.getParent(0);
String reAggNodeStr = reAggNode.toExplainPlanString().toLowerCase();
// Find scan node.
p = pns.get(1);
assertEquals(1, p.getScanNodeList().size());
p = p.getScanNodeList().get(0);
String scanNodeStr = p.toExplainPlanString().toLowerCase();
if (aggFilters != null) {
String[] aggFilterStrings = null;
if (aggFilters instanceof String) {
aggFilterStrings = new String[] { (String) aggFilters };
} else {
aggFilterStrings = (String[]) aggFilters;
}
for (String aggFilter : aggFilterStrings) {
//* enable to debug */ System.out.println(reAggNodeStr.contains(aggFilter.toLowerCase()));
assertTrue(reAggNodeStr.contains(aggFilter.toLowerCase()));
//* enable to debug */ System.out.println(scanNodeStr.contains(aggFilter.toLowerCase()));
assertFalse(scanNodeStr.contains(aggFilter.toLowerCase()));
}
} else {
assertNull(reAggNode.getPostPredicate());
}
if (scanFilters != null) {
String[] scanFilterStrings = null;
if (scanFilters instanceof String) {
scanFilterStrings = new String[] { (String) scanFilters };
} else {
scanFilterStrings = (String[]) scanFilters;
}
for (String scanFilter : scanFilterStrings) {
//* enable to debug */ System.out.println(reAggNodeStr.contains(scanFilter.toLowerCase()));
assertFalse(reAggNodeStr.contains(scanFilter.toLowerCase()));
//* enable to debug */ System.out.println(scanNodeStr.contains(scanFilter.toLowerCase()));
assertTrue(scanNodeStr.contains(scanFilter.toLowerCase()));
}
}
}
Aggregations