use of org.voltdb.expressions.AbstractSubqueryExpression in project voltdb by VoltDB.
the class TestPlansInExistsSubQueries method testInToExistsComplex.
public void testInToExistsComplex() {
AbstractPlanNode pn = compile("select * from R1 where (A,C) in (select 2, C from r2 where r2.c > r1.c group by c)");
pn = pn.getChild(0);
assertTrue(pn instanceof AbstractScanPlanNode);
AbstractScanPlanNode spn = (AbstractScanPlanNode) pn;
AbstractExpression e = spn.getPredicate();
assertEquals(ExpressionType.OPERATOR_EXISTS, e.getExpressionType());
AbstractSubqueryExpression subExpr = (AbstractSubqueryExpression) e.getLeft();
assertEquals(3, subExpr.getArgs().size());
assertEquals(3, subExpr.getParameterIdxList().size());
}
use of org.voltdb.expressions.AbstractSubqueryExpression in project voltdb by VoltDB.
the class TestPlansInExistsSubQueries method verifyTrivialSchemaLimitOffset.
private void verifyTrivialSchemaLimitOffset(AbstractExpression exists, int limit, int offset) {
assertNotNull(exists);
assertEquals(ExpressionType.OPERATOR_EXISTS, exists.getExpressionType());
AbstractSubqueryExpression se = (AbstractSubqueryExpression) exists.getLeft();
AbstractPlanNode pn = se.getSubqueryNode();
assertTrue(pn instanceof SeqScanPlanNode);
AbstractPlanNode inline = pn.getInlinePlanNode(PlanNodeType.PROJECTION);
assertNotNull(inline);
inline = pn.getInlinePlanNode(PlanNodeType.LIMIT);
assertNotNull(inline);
assertEquals(limit, ((LimitPlanNode) inline).getLimit());
assertEquals(offset, ((LimitPlanNode) inline).getOffset());
}
use of org.voltdb.expressions.AbstractSubqueryExpression in project voltdb by VoltDB.
the class AbstractJoinPlanNode method generateOutputSchema.
@Override
public void generateOutputSchema(Database db) {
// Assert and provide functionality for generic join
assert (m_children.size() == 2);
for (AbstractPlanNode child : m_children) {
child.generateOutputSchema(db);
}
// Generate the output schema for subqueries
Collection<AbstractExpression> subqueryExpressions = findAllSubquerySubexpressions();
for (AbstractExpression expr : subqueryExpressions) {
((AbstractSubqueryExpression) expr).generateOutputSchema(db);
}
// Join the schema together to form the output schema
m_outputSchemaPreInlineAgg = m_children.get(0).getOutputSchema().join(m_children.get(1).getOutputSchema()).copyAndReplaceWithTVE();
m_hasSignificantOutputSchema = true;
generateRealOutputSchema(db);
}
use of org.voltdb.expressions.AbstractSubqueryExpression in project voltdb by VoltDB.
the class AbstractPlanNode method overrideId.
public int overrideId(int newId) {
m_id = newId++;
// Override subqueries ids
Collection<AbstractExpression> subqueries = findAllSubquerySubexpressions();
for (AbstractExpression expr : subqueries) {
assert (expr instanceof AbstractSubqueryExpression);
AbstractSubqueryExpression subquery = (AbstractSubqueryExpression) expr;
// overrideSubqueryNodeIds(newId) will get an NPE if the subquery
// has not been planned, presumably the effect of hitting a bug
// earlier in the planner. If that happens again, it MAY be useful
// to preempt those cases here and single-step through a replay of
// findAllSubquerySubexpressions. Determining where in the parent
// plan this subquery expression was found MAY provide a clue
// as to why the subquery was not planned. It has helped before.
//REDO to debug*/ if (subquery instanceof SelectSubqueryExpression) {
//REDO to debug*/ CompiledPlan subqueryPlan = ((SelectSubqueryExpression)subquery)
//REDO to debug*/ .getSubqueryScan().getBestCostPlan();
//REDO to debug*/ if (subqueryPlan == null) {
//REDO to debug*/ findAllSubquerySubexpressions();
//REDO to debug*/ }
//REDO to debug*/ }
newId = subquery.overrideSubqueryNodeIds(newId);
}
return newId;
}
use of org.voltdb.expressions.AbstractSubqueryExpression in project voltdb by VoltDB.
the class TestPlansScalarSubQueries method testSelectParameterScalar.
public void testSelectParameterScalar() {
AbstractPlanNode pn = compile("select r2.c, (select d from r1 where r1.c = ? ) scalar from r2");
pn = pn.getChild(0);
assertTrue(pn instanceof AbstractScanPlanNode);
AbstractPlanNode proj = pn.getInlinePlanNode(PlanNodeType.PROJECTION);
NodeSchema schema = proj.getOutputSchema();
assertEquals(2, schema.size());
SchemaColumn col = schema.getColumns().get(1);
assertTrue(col != null);
assertEquals("SCALAR", col.getColumnName());
AbstractExpression colExpr = col.getExpression();
assertEquals(ExpressionType.VALUE_SCALAR, colExpr.getExpressionType());
assertTrue(colExpr.getLeft() instanceof AbstractSubqueryExpression);
AbstractSubqueryExpression subqueryExpr = (AbstractSubqueryExpression) colExpr.getLeft();
AbstractPlanNode subquery = subqueryExpr.getSubqueryNode();
assertEquals(PlanNodeType.SEQSCAN, subquery.getPlanNodeType());
AbstractExpression pred = ((SeqScanPlanNode) subquery).getPredicate();
assertEquals(ExpressionType.VALUE_PARAMETER, pred.getRight().getExpressionType());
}
Aggregations