use of org.voltdb.plannodes.SendPlanNode in project voltdb by VoltDB.
the class TestWindowedFunctions method validateQueryWithSubquery.
/**
* Validate that each similar windowed query in testRankWithSubqueries
* produces a similar plan
* @param windowedQuery a variant of a test query of a known basic format
**/
private void validateQueryWithSubquery(String windowedQuery, boolean waiveAliasMatch) {
AbstractPlanNode node = compile(windowedQuery);
// Dissect the plan.
assertTrue(node instanceof SendPlanNode);
AbstractPlanNode projectionPlanNode = node.getChild(0);
assertTrue(projectionPlanNode instanceof ProjectionPlanNode);
AbstractPlanNode partitionByPlanNode = projectionPlanNode.getChild(0);
assertTrue(partitionByPlanNode instanceof WindowFunctionPlanNode);
AbstractPlanNode orderByPlanNode = partitionByPlanNode.getChild(0);
assertTrue(orderByPlanNode instanceof OrderByPlanNode);
NodeSchema input_schema = orderByPlanNode.getOutputSchema();
AbstractPlanNode scanNode = orderByPlanNode.getChild(0);
assertTrue(scanNode instanceof NestLoopPlanNode);
NodeSchema schema = partitionByPlanNode.getOutputSchema();
SchemaColumn column = schema.getColumns().get(0);
assertEquals("ARANK", column.getColumnAlias());
validateTVEs(input_schema, (WindowFunctionPlanNode) partitionByPlanNode, waiveAliasMatch);
}
use of org.voltdb.plannodes.SendPlanNode in project voltdb by VoltDB.
the class testPlannerTester method testWriteAndLoad.
public void testWriteAndLoad() throws Exception {
AbstractPlanNode pn = null;
plannerTester.setUpForTest(m_currentDir + "tests/frontend/org/voltdb/planner/testplans-plannerTester-ddl.sql", "testplans-plannerTester-ddl");
List<AbstractPlanNode> pnList = plannerTester.testCompile("select * from l, t where t.a=l.a limit ?;");
System.out.println(pnList.size());
pn = pnList.get(0);
assert (pnList.get(1) instanceof SendPlanNode);
pn.reattachFragment(pnList.get(1));
System.out.println(pn.toJSONString());
System.out.println(pn.toExplainPlanString());
plannerTester.writePlanToFile(pn, m_homeDir, "prettyJson.txt", "");
ArrayList<String> getsql = new ArrayList<String>();
AbstractPlanNode pn2 = plannerTester.loadPlanFromFile(m_homeDir + "prettyJson.txt", getsql);
System.out.println(pn2.toExplainPlanString());
ArrayList<AbstractPlanNode> list1 = pn.getPlanNodeList();
ArrayList<AbstractPlanNode> list2 = pn2.getPlanNodeList();
assertTrue(list1.size() == list2.size());
for (int i = 0; i < list1.size(); i++) {
Map<PlanNodeType, AbstractPlanNode> inlineNodes1 = list1.get(i).getInlinePlanNodes();
Map<PlanNodeType, AbstractPlanNode> inlineNodes2 = list2.get(i).getInlinePlanNodes();
if (inlineNodes1 != null) {
assertTrue(inlineNodes1.size() == inlineNodes2.size());
}
}
}
use of org.voltdb.plannodes.SendPlanNode in project voltdb by VoltDB.
the class testPlannerTester method testReAttachFragments.
public void testReAttachFragments() {
try {
plannerTester.setUpForTest(m_currentDir + "tests/frontend/org/voltdb/planner/testplans-plannerTester-ddl.sql", "testplans-plannerTester-ddl");
List<AbstractPlanNode> pnList = plannerTester.testCompile("select * from l, t where t.a=l.a limit ?;");
System.out.println(pnList.size());
System.out.println(pnList.get(0).toExplainPlanString());
assert (pnList.size() == 2);
assert (pnList.get(1) instanceof SendPlanNode);
if (pnList.get(0).reattachFragment(pnList.get(1))) {
AbstractPlanNode pn = pnList.get(0);
System.out.println(pn.toExplainPlanString());
assertTrue(pn.toExplainPlanString().contains("SEND PARTITION RESULTS TO COORDINATOR"));
}
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.voltdb.plannodes.SendPlanNode in project voltdb by VoltDB.
the class PlanAssembler method handleMVBasedMultiPartQuery.
private AbstractPlanNode handleMVBasedMultiPartQuery(HashAggregatePlanNode reAggNode, AbstractPlanNode root, boolean edgeCaseOuterJoin) {
MaterializedViewFixInfo mvFixInfo = m_parsedSelect.m_mvFixInfo;
AbstractPlanNode receiveNode = root;
AbstractPlanNode reAggParent = null;
// re-aggregation plan node.
if (root instanceof AbstractReceivePlanNode) {
root = reAggNode;
} else {
List<AbstractPlanNode> recList = root.findAllNodesOfClass(AbstractReceivePlanNode.class);
assert (recList.size() == 1);
receiveNode = recList.get(0);
reAggParent = receiveNode.getParent(0);
boolean result = reAggParent.replaceChild(receiveNode, reAggNode);
assert (result);
}
reAggNode.addAndLinkChild(receiveNode);
reAggNode.m_isCoordinatingAggregator = true;
assert (receiveNode instanceof ReceivePlanNode);
AbstractPlanNode sendNode = receiveNode.getChild(0);
assert (sendNode instanceof SendPlanNode);
AbstractPlanNode sendNodeChild = sendNode.getChild(0);
HashAggregatePlanNode reAggNodeForReplace = null;
if (m_parsedSelect.m_tableList.size() > 1 && !edgeCaseOuterJoin) {
reAggNodeForReplace = reAggNode;
}
boolean find = mvFixInfo.processScanNodeWithReAggNode(sendNode, reAggNodeForReplace);
assert (find);
// receive node with materialized view scan node.
if (m_parsedSelect.m_tableList.size() > 1 && !edgeCaseOuterJoin) {
AbstractPlanNode joinNode = sendNodeChild;
// No agg, limit pushed down at this point.
assert (joinNode instanceof AbstractJoinPlanNode);
// Fix the node after Re-aggregation node.
joinNode.clearParents();
assert (mvFixInfo.m_scanNode != null);
mvFixInfo.m_scanNode.clearParents();
// replace joinNode with MV scan node on each partition.
sendNode.clearChildren();
sendNode.addAndLinkChild(mvFixInfo.m_scanNode);
// its parent will be the parent of the new join node. Update the root node.
if (reAggParent != null) {
reAggParent.replaceChild(reAggNode, joinNode);
root = reAggParent;
} else {
root = joinNode;
}
}
return root;
}
use of org.voltdb.plannodes.SendPlanNode in project voltdb by VoltDB.
the class PlanAssembler method removeCoordinatorSendReceivePairRecursive.
private static AbstractPlanNode removeCoordinatorSendReceivePairRecursive(AbstractPlanNode root, AbstractPlanNode current) {
if (current instanceof AbstractReceivePlanNode) {
assert (current.getChildCount() == 1);
AbstractPlanNode child = current.getChild(0);
assert (child instanceof SendPlanNode);
assert (child.getChildCount() == 1);
child = child.getChild(0);
child.clearParents();
if (current == root) {
return child;
}
assert (current.getParentCount() == 1);
AbstractPlanNode parent = current.getParent(0);
parent.unlinkChild(current);
parent.addAndLinkChild(child);
return root;
}
if (current.getChildCount() == 1) {
// This is still a coordinator node
return removeCoordinatorSendReceivePairRecursive(root, current.getChild(0));
}
// I'm not sure what the correct behavior is for a union.
return root;
}
Aggregations