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);
}
}
Aggregations