use of org.voltdb.types.PlanNodeType in project voltdb by VoltDB.
the class TestPlansDML method testDeleteOrderByPlan.
public void testDeleteOrderByPlan() {
System.out.println("\n\n\nRUNNING testDeleteOrderByPlan\n\n");
List<AbstractPlanNode> pns;
PlanNodeType[] deleteFromIndexScan = { PlanNodeType.SEND, PlanNodeType.DELETE, PlanNodeType.INDEXSCAN };
PlanNodeType[] deleteFromSortedIndexScan = { PlanNodeType.SEND, PlanNodeType.DELETE, PlanNodeType.ORDERBY, PlanNodeType.INDEXSCAN };
PlanNodeType[] deleteFromSortedSeqScan = { PlanNodeType.SEND, PlanNodeType.DELETE, PlanNodeType.ORDERBY, PlanNodeType.SEQSCAN };
// No ORDER BY node, since we can use index instead
pns = compileToFragments("DELETE FROM R5 ORDER BY A LIMIT ?");
assertEquals(2, pns.size());
AbstractPlanNode collectorRoot = pns.get(1);
assertLeftChain(collectorRoot, deleteFromIndexScan);
// No ORDER BY node, since index scan is used to evaluate predicate
pns = compileToFragments("DELETE FROM R5 WHERE A = 1 ORDER BY A LIMIT ?");
assertEquals(2, pns.size());
collectorRoot = pns.get(1);
assertLeftChain(collectorRoot, deleteFromIndexScan);
// Index used to evaluate predicate not suitable for ORDER BY
pns = compileToFragments("DELETE FROM R5 WHERE A = 1 ORDER BY B, A, C, D LIMIT ?");
assertEquals(2, pns.size());
collectorRoot = pns.get(1);
assertLeftChain(collectorRoot, deleteFromSortedIndexScan);
// Index can't be used either for predicate evaluation or ORDER BY
pns = compileToFragments("DELETE FROM R5 WHERE B = 1 ORDER BY B, A, C, D LIMIT ?");
assertEquals(2, pns.size());
collectorRoot = pns.get(1);
assertLeftChain(collectorRoot, deleteFromSortedSeqScan);
}
use of org.voltdb.types.PlanNodeType in project voltdb by VoltDB.
the class TestPlansDML method checkDMLPlanNodeAndSubqueryExpression.
void checkDMLPlanNodeAndSubqueryExpression(String dmlSQL, ExpressionType filterType) {
List<AbstractPlanNode> pns = compileToFragments(dmlSQL);
AbstractPlanNode dmlNode;
if (pns.size() == 2) {
dmlNode = pns.get(1).getChild(0);
} else {
dmlNode = pns.get(0);
}
String dmlType = dmlSQL.substring(0, dmlSQL.indexOf(' ')).trim().toUpperCase();
if ("UPSERT".equalsIgnoreCase(dmlType)) {
// UPSERT is INSERT
dmlType = "INSERT";
}
// it could be extended in some way.
if ((dmlNode instanceof SeqScanPlanNode) && "INSERT".equals(dmlType)) {
assertNotNull("Expected an insert node.", dmlNode.getInlinePlanNode(PlanNodeType.INSERT));
} else {
assertEquals(dmlType, dmlNode.getPlanNodeType().toString());
}
PlanNodeType nodeType = dmlNode.getPlanNodeType();
while (nodeType != PlanNodeType.SEQSCAN && nodeType != PlanNodeType.MATERIALIZE && nodeType != PlanNodeType.INDEXSCAN) {
dmlNode = dmlNode.getChild(0);
nodeType = dmlNode.getPlanNodeType();
}
assertNotNull(dmlNode);
// Verify DML Predicate
if (filterType != null) {
AbstractExpression predicate = ((AbstractScanPlanNode) dmlNode).getPredicate();
assertNotNull(predicate);
assertEquals(filterType, predicate.getExpressionType());
assertTrue(predicate.hasAnySubexpressionOfClass(SelectSubqueryExpression.class));
}
}
use of org.voltdb.types.PlanNodeType 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.types.PlanNodeType in project voltdb by VoltDB.
the class PlannerTestCase method followAssertedLeftChain.
/**
* Find a specific node in a plan tree following the left-most path,
* (child[0]), and asserting the expected class of each plan node along the
* way, inclusive of the start and end.
* @param expectedClasses a list of expected AbstractPlanNode classes
* @param actualPlan the top of a plan node tree expected to have instances
* of the expected classes along its left-most branch
* listed in top-down order.
* @return the child node matching the last expected class in the list.
* It need not be a leaf node.
*/
protected static AbstractPlanNode followAssertedLeftChain(AbstractPlanNode start, PlanNodeType startType, PlanNodeType... nodeTypes) {
AbstractPlanNode result = start;
assertEquals(startType, result.getPlanNodeType());
for (PlanNodeType type : nodeTypes) {
assertTrue(result.getChildCount() > 0);
result = result.getChild(0);
assertEquals(type, result.getPlanNodeType());
}
return result;
}
Aggregations