Search in sources :

Example 16 with AbstractSubqueryExpression

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());
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode) SeqScanPlanNode(org.voltdb.plannodes.SeqScanPlanNode) AbstractSubqueryExpression(org.voltdb.expressions.AbstractSubqueryExpression)

Example 17 with AbstractSubqueryExpression

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);
}
Also used : AbstractExpression(org.voltdb.expressions.AbstractExpression) AbstractSubqueryExpression(org.voltdb.expressions.AbstractSubqueryExpression)

Example 18 with AbstractSubqueryExpression

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;
}
Also used : AbstractExpression(org.voltdb.expressions.AbstractExpression) AbstractSubqueryExpression(org.voltdb.expressions.AbstractSubqueryExpression)

Aggregations

AbstractSubqueryExpression (org.voltdb.expressions.AbstractSubqueryExpression)18 AbstractExpression (org.voltdb.expressions.AbstractExpression)16 AbstractPlanNode (org.voltdb.plannodes.AbstractPlanNode)10 AbstractScanPlanNode (org.voltdb.plannodes.AbstractScanPlanNode)7 SeqScanPlanNode (org.voltdb.plannodes.SeqScanPlanNode)4 AggregatePlanNode (org.voltdb.plannodes.AggregatePlanNode)3 LimitPlanNode (org.voltdb.plannodes.LimitPlanNode)2 NodeSchema (org.voltdb.plannodes.NodeSchema)2 SchemaColumn (org.voltdb.plannodes.SchemaColumn)2 ArrayList (java.util.ArrayList)1 JSONObject (org.json_voltpatches.JSONObject)1 Index (org.voltdb.catalog.Index)1 TupleValueExpression (org.voltdb.expressions.TupleValueExpression)1 IndexScanPlanNode (org.voltdb.plannodes.IndexScanPlanNode)1 IndexSortablePlanNode (org.voltdb.plannodes.IndexSortablePlanNode)1 IndexUseForOrderBy (org.voltdb.plannodes.IndexUseForOrderBy)1 MaterializedScanPlanNode (org.voltdb.plannodes.MaterializedScanPlanNode)1