Search in sources :

Example 1 with SysUpdateProjection

use of io.crate.execution.dsl.projection.SysUpdateProjection in project crate by crate.

the class UpdatePlanner method sysUpdate.

private static ExecutionPlan sysUpdate(PlannerContext plannerContext, TableRelation table, Map<Reference, Symbol> assignmentByTargetCol, Symbol query, Row params, SubQueryResults subQueryResults, @Nullable List<Symbol> returnValues) {
    TableInfo tableInfo = table.tableInfo();
    Reference idReference = requireNonNull(tableInfo.getReference(DocSysColumns.ID), "Table must have a _id column");
    Symbol[] outputSymbols;
    if (returnValues == null) {
        outputSymbols = new Symbol[] { new InputColumn(0, DataTypes.LONG) };
    } else {
        outputSymbols = new Symbol[returnValues.size()];
        for (int i = 0; i < returnValues.size(); i++) {
            outputSymbols[i] = new InputColumn(i, returnValues.get(i).valueType());
        }
    }
    SysUpdateProjection updateProjection = new SysUpdateProjection(new InputColumn(0, idReference.valueType()), assignmentByTargetCol, outputSymbols, returnValues == null ? null : returnValues.toArray(new Symbol[0]));
    WhereClause where = new WhereClause(SubQueryAndParamBinder.convert(query, params, subQueryResults));
    if (returnValues == null) {
        return createCollectAndMerge(plannerContext, tableInfo, idReference, updateProjection, where, 1, 1, MergeCountProjection.INSTANCE);
    } else {
        return createCollectAndMerge(plannerContext, tableInfo, idReference, updateProjection, where, updateProjection.outputs().size(), -1);
    }
}
Also used : SysUpdateProjection(io.crate.execution.dsl.projection.SysUpdateProjection) Reference(io.crate.metadata.Reference) SelectSymbol(io.crate.expression.symbol.SelectSymbol) Symbol(io.crate.expression.symbol.Symbol) InputColumn(io.crate.expression.symbol.InputColumn) WhereClause(io.crate.analyze.WhereClause) DocTableInfo(io.crate.metadata.doc.DocTableInfo) TableInfo(io.crate.metadata.table.TableInfo)

Aggregations

WhereClause (io.crate.analyze.WhereClause)1 SysUpdateProjection (io.crate.execution.dsl.projection.SysUpdateProjection)1 InputColumn (io.crate.expression.symbol.InputColumn)1 SelectSymbol (io.crate.expression.symbol.SelectSymbol)1 Symbol (io.crate.expression.symbol.Symbol)1 Reference (io.crate.metadata.Reference)1 DocTableInfo (io.crate.metadata.doc.DocTableInfo)1 TableInfo (io.crate.metadata.table.TableInfo)1