Search in sources :

Example 51 with AbstractExpression

use of org.voltdb.expressions.AbstractExpression in project voltdb by VoltDB.

the class TupleScanPlanNode method explainPlanForNode.

@Override
public String explainPlanForNode(String indent) {
    String result = "(";
    String connector = "";
    for (AbstractExpression arg : m_columnList) {
        result += connector + arg.explain(indent);
        connector = ", ";
    }
    result += ")";
    return result;
}
Also used : AbstractExpression(org.voltdb.expressions.AbstractExpression)

Example 52 with AbstractExpression

use of org.voltdb.expressions.AbstractExpression in project voltdb by VoltDB.

the class TupleScanPlanNode method resolveColumnIndexes.

@Override
public void resolveColumnIndexes() {
    // output columns
    for (SchemaColumn col : m_outputSchema.getColumns()) {
        AbstractExpression colExpr = col.getExpression();
        // At this point, they'd better all be TVEs.
        assert (colExpr instanceof TupleValueExpression);
        TupleValueExpression tve = (TupleValueExpression) colExpr;
        tve.setColumnIndexUsingSchema(m_tableSchema);
    }
    m_outputSchema.sortByTveIndex();
}
Also used : TupleValueExpression(org.voltdb.expressions.TupleValueExpression) AbstractExpression(org.voltdb.expressions.AbstractExpression)

Example 53 with AbstractExpression

use of org.voltdb.expressions.AbstractExpression in project voltdb by VoltDB.

the class WindowFunctionPlanNode method resolveColumnIndexesUsingSchema.

public void resolveColumnIndexesUsingSchema(NodeSchema inputSchema) {
    Collection<TupleValueExpression> allTves;
    // get all the TVEs in the output columns
    for (SchemaColumn col : m_outputSchema.getColumns()) {
        AbstractExpression colExpr = col.getExpression();
        allTves = ExpressionUtil.getTupleValueExpressions(colExpr);
        for (TupleValueExpression tve : allTves) {
            int index = tve.setColumnIndexUsingSchema(inputSchema);
            if (index == -1) {
                // check to see if this TVE is the aggregate output
                if (!tve.getTableName().equals(AbstractParsedStmt.TEMP_TABLE_NAME)) {
                    throw new RuntimeException("Unable to find index for column: " + tve.getColumnName());
                }
            }
        }
    }
    // sure these should be TVEs in the long term.
    for (List<AbstractExpression> agg_exps : m_aggregateExpressions) {
        if (agg_exps != null) {
            for (AbstractExpression agg_exp : agg_exps) {
                allTves = ExpressionUtil.getTupleValueExpressions(agg_exp);
                for (TupleValueExpression tve : allTves) {
                    tve.setColumnIndexUsingSchema(inputSchema);
                }
            }
        }
    }
    // Aggregates also need to resolve indexes for partition by inputs
    for (AbstractExpression group_exp : m_partitionByExpressions) {
        allTves = ExpressionUtil.getTupleValueExpressions(group_exp);
        for (TupleValueExpression tve : allTves) {
            tve.setColumnIndexUsingSchema(inputSchema);
        }
    }
    // one, which is the general case.
    for (AbstractExpression obExpr : m_orderByExpressions) {
        allTves = ExpressionUtil.getTupleValueExpressions(obExpr);
        for (TupleValueExpression tve : allTves) {
            tve.setColumnIndexUsingSchema(inputSchema);
        }
    }
    /*
         * Is this needed?
         */
    resolveSubqueryColumnIndexes();
}
Also used : TupleValueExpression(org.voltdb.expressions.TupleValueExpression) AbstractExpression(org.voltdb.expressions.AbstractExpression)

Example 54 with AbstractExpression

use of org.voltdb.expressions.AbstractExpression in project voltdb by VoltDB.

the class NestLoopIndexPlanNode method generateOutputSchema.

@Override
public void generateOutputSchema(Database db) {
    // Important safety tip regarding this inlined
    // index scan and ITS inlined projection:
    // That projection is currently only used/usable as
    // a means to narrow the set of columns from the
    // indexscan's target table that make it into the
    // rest of the plan.  the expressions that are
    // given to the projection are currently not ever used
    IndexScanPlanNode inlineScan = (IndexScanPlanNode) m_inlineNodes.get(PlanNodeType.INDEXSCAN);
    assert (inlineScan != null);
    inlineScan.generateOutputSchema(db);
    assert (m_children.size() == 1);
    m_children.get(0).generateOutputSchema(db);
    // Join the schema together to form the output schema
    // The child subplan's output is the outer table
    // The inlined node's output is the inner table.
    //
    // Note that the inner table's contribution to the join_tuple doesn't include
    // all the columns from the inner table---just the ones needed as determined by
    // the inlined scan's own inlined projection, as described above.
    m_outputSchemaPreInlineAgg = m_children.get(0).getOutputSchema().join(inlineScan.getOutputSchema()).copyAndReplaceWithTVE();
    m_hasSignificantOutputSchema = true;
    generateRealOutputSchema(db);
    // Generate the output schema for subqueries
    Collection<AbstractExpression> subqueryExpressions = findAllSubquerySubexpressions();
    for (AbstractExpression subqueryExpression : subqueryExpressions) {
        assert (subqueryExpression instanceof AbstractSubqueryExpression);
        ((AbstractSubqueryExpression) subqueryExpression).generateOutputSchema(db);
    }
}
Also used : AbstractExpression(org.voltdb.expressions.AbstractExpression) AbstractSubqueryExpression(org.voltdb.expressions.AbstractSubqueryExpression)

Example 55 with AbstractExpression

use of org.voltdb.expressions.AbstractExpression in project voltdb by VoltDB.

the class NodeSchema method addAllSubexpressionsOfClassFromNodeSchema.

public void addAllSubexpressionsOfClassFromNodeSchema(Set<AbstractExpression> exprs, Class<? extends AbstractExpression> aeClass) {
    for (SchemaColumn column : getColumns()) {
        AbstractExpression colExpr = column.getExpression();
        if (colExpr == null) {
            continue;
        }
        Collection<AbstractExpression> found = colExpr.findAllSubexpressionsOfClass(aeClass);
        exprs.addAll(found);
    }
}
Also used : AbstractExpression(org.voltdb.expressions.AbstractExpression)

Aggregations

AbstractExpression (org.voltdb.expressions.AbstractExpression)215 TupleValueExpression (org.voltdb.expressions.TupleValueExpression)59 AbstractPlanNode (org.voltdb.plannodes.AbstractPlanNode)55 ArrayList (java.util.ArrayList)43 SeqScanPlanNode (org.voltdb.plannodes.SeqScanPlanNode)26 SchemaColumn (org.voltdb.plannodes.SchemaColumn)25 NestLoopPlanNode (org.voltdb.plannodes.NestLoopPlanNode)23 Constraint (org.voltdb.catalog.Constraint)22 IndexScanPlanNode (org.voltdb.plannodes.IndexScanPlanNode)22 HashSet (java.util.HashSet)21 Column (org.voltdb.catalog.Column)21 AbstractScanPlanNode (org.voltdb.plannodes.AbstractScanPlanNode)21 JSONException (org.json_voltpatches.JSONException)19 ColumnRef (org.voltdb.catalog.ColumnRef)19 Table (org.voltdb.catalog.Table)17 AbstractSubqueryExpression (org.voltdb.expressions.AbstractSubqueryExpression)16 ParameterValueExpression (org.voltdb.expressions.ParameterValueExpression)16 StmtTableScan (org.voltdb.planner.parseinfo.StmtTableScan)16 ExpressionType (org.voltdb.types.ExpressionType)16 VoltXMLElement (org.hsqldb_voltpatches.VoltXMLElement)14