use of io.crate.expression.symbol.SelectSymbol in project crate by crate.
the class UpdatePlanner method plan.
public static Plan plan(AnalyzedUpdateStatement update, PlannerContext plannerCtx, SubqueryPlanner subqueryPlanner) {
if (update.outputs() != null && !plannerCtx.clusterState().getNodes().getMinNodeVersion().onOrAfter(Version.V_4_2_0)) {
throw new UnsupportedFeatureException(RETURNING_VERSION_ERROR_MSG);
}
AbstractTableRelation<?> table = update.table();
Plan plan;
if (table instanceof DocTableRelation) {
DocTableRelation docTable = (DocTableRelation) table;
plan = plan(docTable, update.assignmentByTargetCol(), update.query(), plannerCtx, update.outputs());
} else {
plan = new Update((plannerContext, params, subQueryValues) -> sysUpdate(plannerContext, (TableRelation) table, update.assignmentByTargetCol(), update.query(), params, subQueryValues, update.outputs()));
}
Map<LogicalPlan, SelectSymbol> subQueries = subqueryPlanner.planSubQueries(update);
return MultiPhasePlan.createIfNeeded(plan, subQueries);
}
use of io.crate.expression.symbol.SelectSymbol in project crate by crate.
the class UpdatePlannerTest method testMultiValueSubQueryWithinSingleValueSubQueryDoesNotInheritSoftLimit.
@Test
public void testMultiValueSubQueryWithinSingleValueSubQueryDoesNotInheritSoftLimit() {
MultiPhasePlan plan = e.plan("update users set ints = (" + " select count(id) from users where id in (select unnest([1, 2, 3, 4])))");
assertThat(plan.rootPlan, instanceOf(UpdatePlanner.Update.class));
Map<LogicalPlan, SelectSymbol> rootPlanDependencies = plan.dependencies;
LogicalPlan outerSubSelectPlan = rootPlanDependencies.keySet().iterator().next();
SelectSymbol outerSubSelectSymbol = rootPlanDependencies.values().iterator().next();
assertThat(outerSubSelectSymbol.getResultType(), is(SINGLE_COLUMN_SINGLE_VALUE));
assertThat(outerSubSelectPlan.numExpectedRows(), is(2L));
LogicalPlan innerSubSelectPlan = outerSubSelectPlan.dependencies().keySet().iterator().next();
SelectSymbol innerSubSelectSymbol = outerSubSelectPlan.dependencies().values().iterator().next();
assertThat(innerSubSelectSymbol.getResultType(), is(SINGLE_COLUMN_MULTIPLE_VALUES));
assertThat(innerSubSelectPlan.numExpectedRows(), is(-1L));
}
Aggregations