use of org.voltdb.plannodes.SeqScanPlanNode in project voltdb by VoltDB.
the class TestWindowedFunctions method validatePartitionedQuery.
private void validatePartitionedQuery(String query, boolean hasStatementOrderBy) {
List<AbstractPlanNode> nodes = compileToFragments(query);
assertEquals(2, nodes.size());
AbstractPlanNode child = nodes.get(0);
// Validate the coordinator fragment.
assertTrue(child instanceof SendPlanNode);
child = child.getChild(0);
assertTrue(child instanceof ProjectionPlanNode);
if (hasStatementOrderBy) {
child = child.getChild(0);
assertTrue(child instanceof OrderByPlanNode);
}
child = child.getChild(0);
assertTrue(child instanceof WindowFunctionPlanNode);
child = child.getChild(0);
assertTrue(child instanceof OrderByPlanNode);
child = child.getChild(0);
assertTrue(child instanceof ReceivePlanNode);
assertEquals(0, child.getChildCount());
// Get the distributed fragment.
child = nodes.get(1);
assertTrue(child instanceof SendPlanNode);
child = child.getChild(0);
assertTrue(child instanceof SeqScanPlanNode);
assertEquals(0, child.getChildCount());
}
use of org.voltdb.plannodes.SeqScanPlanNode in project voltdb by VoltDB.
the class TestUnion method testSelfUnion.
public void testSelfUnion() {
AbstractPlanNode pn = compile("select B from T2 UNION select B from T2");
assertTrue(pn.getChild(0) instanceof UnionPlanNode);
pn = pn.getChild(0);
assertTrue(pn.getChildCount() == 2);
assertTrue(pn.getChild(0) instanceof SeqScanPlanNode);
assertTrue(pn.getChild(1) instanceof SeqScanPlanNode);
// The same table/alias is repeated twice in the union but in the different selects
pn = compile("select A1.B from T2 A1, T2 A2 WHERE A1.B = A2.B UNION select B from T2 A1");
assertTrue(pn.getChild(0) instanceof UnionPlanNode);
pn = pn.getChild(0);
assertTrue(pn.getChildCount() == 2);
assertTrue(pn.getChild(0) instanceof ProjectionPlanNode);
assertTrue(pn.getChild(0).getChild(0) instanceof NestLoopPlanNode);
assertTrue(pn.getChild(1) instanceof SeqScanPlanNode);
// BOTH sides are single-partitioned for the same partition
pn = compile("select F from T1 WHERE T1.A = 2 UNION select F from T1 WHERE T1.A = 2");
assertTrue(pn.getChild(0) instanceof UnionPlanNode);
// If BOTH sides are single-partitioned, but for different partitions,
// it would theoretically be possible to satisfy
// the query with a 2-fragment plan IFF the coordinator fragment could be forced to
// execute on one of the designated single partitions.
// At this point, coordinator designation is only supported for single-fragment plans.
failToCompile("select DESC from T1 WHERE A = 1 UNION select DESC from T1 WHERE A = 2");
// If both sides are multi-partitioned, there is no facility for pushing down the
// union processing below the send/receive, so each child of the union requires
// its own send/receive so the plan ends up as an unsupported 3-fragment plan.
failToCompile("select DESC from T1 UNION select DESC from T1");
}
use of org.voltdb.plannodes.SeqScanPlanNode in project voltdb by VoltDB.
the class TestWindowedFunctions method validateWindowedFunctionPlan.
/**
* Validate that each similar windowed query in testRank produces a similar
* plan, with the expected minor variation to its ORDER BY node.
* @param windowedQuery a variant of a test query of a known basic format
* @param nSorts the expected number of sort criteria that should have been
* extracted from the variant query's PARTITION BY and ORDER BY.
* @param descSortIndex the position among the sort criteria of the original
* ORDER BY column, always distinguishable by its "DESC" direction.
**/
private void validateWindowedFunctionPlan(String windowedQuery, int nSorts, int descSortIndex, int numPartitionExprs, ExpressionType winOpType) {
// Sometimes we get multi-fragment nodes when we
// expect single fragment nodes. Keeping all the fragments
// helps to diagnose the problem.
List<AbstractPlanNode> nodes = compileToFragments(windowedQuery);
assertEquals(1, nodes.size());
AbstractPlanNode node = nodes.get(0);
// The plan should look like:
// SendNode -> ProjectionPlanNode -> PartitionByPlanNode -> OrderByPlanNode -> SeqScanNode
// We also do some sanity checking on the PartitionPlan node.
// First dissect the plan.
assertTrue(node instanceof SendPlanNode);
AbstractPlanNode projPlanNode = node.getChild(0);
assertTrue(projPlanNode instanceof ProjectionPlanNode);
AbstractPlanNode windowFuncPlanNode = projPlanNode.getChild(0);
assertTrue(windowFuncPlanNode instanceof WindowFunctionPlanNode);
AbstractPlanNode abstractOrderByNode = windowFuncPlanNode.getChild(0);
assertTrue(abstractOrderByNode instanceof OrderByPlanNode);
OrderByPlanNode orderByNode = (OrderByPlanNode) abstractOrderByNode;
NodeSchema input_schema = orderByNode.getOutputSchema();
assertNotNull(input_schema);
AbstractPlanNode seqScanNode = orderByNode.getChild(0);
assertTrue(seqScanNode instanceof SeqScanPlanNode || seqScanNode instanceof NestLoopPlanNode);
WindowFunctionPlanNode wfPlanNode = (WindowFunctionPlanNode) windowFuncPlanNode;
NodeSchema schema = wfPlanNode.getOutputSchema();
//
// Check that the window function plan node's output schema is correct.
// Look at the first expression, to verify that it's the windowed expression.
// Then check that the TVEs all make sense.
//
SchemaColumn column = schema.getColumns().get(0);
assertEquals("ARANK", column.getColumnAlias());
assertEquals(numPartitionExprs, wfPlanNode.getPartitionByExpressions().size());
validateTVEs(input_schema, wfPlanNode, false);
//
// Check that the operation is what we expect.
//
assertTrue(wfPlanNode.getAggregateTypes().size() > 0);
assertEquals(winOpType, wfPlanNode.getAggregateTypes().get(0));
//
for (List<AbstractExpression> exprs : wfPlanNode.getAggregateExpressions()) {
if (exprs != null) {
for (AbstractExpression expr : exprs) {
assertNotNull(expr.getValueType());
}
}
}
//
// Check that the order by node has the right number of expressions.
// and that they have the correct order.
//
assertEquals(nSorts, orderByNode.getSortExpressions().size());
int sortIndex = 0;
for (SortDirectionType direction : orderByNode.getSortDirections()) {
SortDirectionType expected = (sortIndex == descSortIndex) ? SortDirectionType.DESC : SortDirectionType.ASC;
assertEquals(expected, direction);
++sortIndex;
}
}
use of org.voltdb.plannodes.SeqScanPlanNode in project voltdb by VoltDB.
the class TestUnion method testSubqueryUnionWithParamENG7783.
public void testSubqueryUnionWithParamENG7783() {
AbstractPlanNode pn = compile("SELECT B, ABS( B - ? ) AS distance FROM ( " + "( SELECT B FROM T2 WHERE B >=? ORDER BY B LIMIT ? " + ") UNION ALL ( " + "SELECT B FROM T2 WHERE B < ? ORDER BY B DESC LIMIT ? ) " + ") AS n ORDER BY distance LIMIT ?;");
assertTrue(pn.getChild(0) instanceof ProjectionPlanNode);
assertTrue(pn.getChild(0).getChild(0) instanceof OrderByPlanNode);
assertTrue(pn.getChild(0).getChild(0).getChild(0) instanceof SeqScanPlanNode);
assertTrue(pn.getChild(0).getChild(0).getChild(0).getChild(0) instanceof UnionPlanNode);
}
use of org.voltdb.plannodes.SeqScanPlanNode in project voltdb by VoltDB.
the class TestSelfJoins method testOuterSelfJoin.
public void testOuterSelfJoin() {
// A.C = B.C Inner-Outer join Expr stays at the NLJ as Join predicate
// A.A > 1 Outer Join Expr stays at the the NLJ as pre-join predicate
// B.A < 0 Inner Join Expr is pushed down to the inner SeqScan node
AbstractPlanNode pn = compile("select * FROM R1 A LEFT JOIN R1 B ON A.C = B.C AND A.A > 1 AND B.A < 0");
pn = pn.getChild(0).getChild(0);
assertTrue(pn instanceof NestLoopPlanNode);
NestLoopPlanNode nl = (NestLoopPlanNode) pn;
assertNotNull(nl.getPreJoinPredicate());
AbstractExpression p = nl.getPreJoinPredicate();
assertEquals(ExpressionType.COMPARE_GREATERTHAN, p.getExpressionType());
assertNotNull(nl.getJoinPredicate());
p = nl.getJoinPredicate();
assertEquals(ExpressionType.COMPARE_EQUAL, p.getExpressionType());
assertNull(nl.getWherePredicate());
assertEquals(2, nl.getChildCount());
SeqScanPlanNode c = (SeqScanPlanNode) nl.getChild(0);
assertNull(c.getPredicate());
c = (SeqScanPlanNode) nl.getChild(1);
assertNotNull(c.getPredicate());
p = c.getPredicate();
assertEquals(ExpressionType.COMPARE_LESSTHAN, p.getExpressionType());
}
Aggregations