Search in sources :

Example 11 with SubQueryResults

use of io.crate.planner.operators.SubQueryResults in project crate by crate.

the class AlterUserPlan method executeOrFail.

@Override
public void executeOrFail(DependencyCarrier dependencies, PlannerContext plannerContext, RowConsumer consumer, Row params, SubQueryResults subQueryResults) throws Exception {
    SecureHash newPassword = UserActions.generateSecureHash(alterUser.properties(), params, plannerContext.transactionContext(), plannerContext.nodeContext());
    userManager.alterUser(alterUser.userName(), newPassword).whenComplete(new OneRowActionListener<>(consumer, rCount -> new Row1(rCount == null ? -1 : rCount)));
}
Also used : RowConsumer(io.crate.data.RowConsumer) DependencyCarrier(io.crate.planner.DependencyCarrier) AnalyzedAlterUser(io.crate.analyze.AnalyzedAlterUser) UserActions(io.crate.user.UserActions) Row(io.crate.data.Row) PlannerContext(io.crate.planner.PlannerContext) Plan(io.crate.planner.Plan) UserManager(io.crate.user.UserManager) SubQueryResults(io.crate.planner.operators.SubQueryResults) SecureHash(io.crate.user.SecureHash) OneRowActionListener(io.crate.execution.support.OneRowActionListener) Row1(io.crate.data.Row1) Row1(io.crate.data.Row1) SecureHash(io.crate.user.SecureHash)

Example 12 with SubQueryResults

use of io.crate.planner.operators.SubQueryResults in project crate by crate.

the class CreateUserPlan method executeOrFail.

@Override
public void executeOrFail(DependencyCarrier dependencies, PlannerContext plannerContext, RowConsumer consumer, Row params, SubQueryResults subQueryResults) throws Exception {
    SecureHash newPassword = UserActions.generateSecureHash(createUser.properties(), params, plannerContext.transactionContext(), plannerContext.nodeContext());
    userManager.createUser(createUser.userName(), newPassword).whenComplete(new OneRowActionListener<>(consumer, rCount -> new Row1(rCount == null ? -1 : rCount)));
}
Also used : RowConsumer(io.crate.data.RowConsumer) DependencyCarrier(io.crate.planner.DependencyCarrier) UserActions(io.crate.user.UserActions) Row(io.crate.data.Row) PlannerContext(io.crate.planner.PlannerContext) Plan(io.crate.planner.Plan) UserManager(io.crate.user.UserManager) SubQueryResults(io.crate.planner.operators.SubQueryResults) SecureHash(io.crate.user.SecureHash) AnalyzedCreateUser(io.crate.analyze.AnalyzedCreateUser) OneRowActionListener(io.crate.execution.support.OneRowActionListener) Row1(io.crate.data.Row1) Row1(io.crate.data.Row1) SecureHash(io.crate.user.SecureHash)

Example 13 with SubQueryResults

use of io.crate.planner.operators.SubQueryResults in project crate by crate.

the class ResetSettingsPlan method executeOrFail.

@Override
public void executeOrFail(DependencyCarrier dependencies, PlannerContext plannerContext, RowConsumer consumer, Row params, SubQueryResults subQueryResults) {
    Function<? super Symbol, Object> eval = x -> SymbolEvaluator.evaluate(plannerContext.transactionContext(), plannerContext.nodeContext(), x, params, subQueryResults);
    Settings settings = buildSettingsFrom(resetAnalyzedStatement.settingsToRemove(), eval);
    ClusterUpdateSettingsRequest request = new ClusterUpdateSettingsRequest().persistentSettings(settings).transientSettings(settings);
    OneRowActionListener<ClusterUpdateSettingsResponse> actionListener = new OneRowActionListener<>(consumer, r -> r.isAcknowledged() ? new Row1(1L) : new Row1(0L));
    dependencies.transportActionProvider().transportClusterUpdateSettingsAction().execute(request, actionListener);
}
Also used : CrateSettings(io.crate.metadata.settings.CrateSettings) AnalyzedResetStatement(io.crate.analyze.AnalyzedResetStatement) Set(java.util.Set) Function(java.util.function.Function) RowConsumer(io.crate.data.RowConsumer) DependencyCarrier(io.crate.planner.DependencyCarrier) List(java.util.List) SymbolEvaluator(io.crate.analyze.SymbolEvaluator) ClusterUpdateSettingsRequest(org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest) Settings(org.elasticsearch.common.settings.Settings) Row(io.crate.data.Row) Symbol(io.crate.expression.symbol.Symbol) PlannerContext(io.crate.planner.PlannerContext) Locale(java.util.Locale) Plan(io.crate.planner.Plan) SubQueryResults(io.crate.planner.operators.SubQueryResults) ClusterUpdateSettingsResponse(org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse) VisibleForTesting(io.crate.common.annotations.VisibleForTesting) OneRowActionListener(io.crate.execution.support.OneRowActionListener) Row1(io.crate.data.Row1) Row1(io.crate.data.Row1) OneRowActionListener(io.crate.execution.support.OneRowActionListener) ClusterUpdateSettingsResponse(org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse) CrateSettings(io.crate.metadata.settings.CrateSettings) Settings(org.elasticsearch.common.settings.Settings) ClusterUpdateSettingsRequest(org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest)

Example 14 with SubQueryResults

use of io.crate.planner.operators.SubQueryResults in project crate by crate.

the class DecommissionNodePlan method executeOrFail.

@Override
public void executeOrFail(DependencyCarrier dependencies, PlannerContext plannerContext, RowConsumer consumer, Row params, SubQueryResults subQueryResults) {
    var boundedNodeIdOrName = boundNodeIdOrName(analyzedDecommissionNode, plannerContext.transactionContext(), plannerContext.nodeContext(), params, subQueryResults);
    String targetNodeId = NodeSelection.resolveNodeId(dependencies.clusterService().state().nodes(), boundedNodeIdOrName);
    dependencies.transportActionProvider().transportDecommissionNodeAction().execute(targetNodeId, new DecommissionNodeRequest(), new OneRowActionListener<>(consumer, r -> r.isAcknowledged() ? new Row1(1L) : new Row1(0L)));
}
Also used : RowConsumer(io.crate.data.RowConsumer) NodeContext(io.crate.metadata.NodeContext) SymbolEvaluator(io.crate.analyze.SymbolEvaluator) Row(io.crate.data.Row) DataTypes(io.crate.types.DataTypes) AnalyzedDecommissionNode(io.crate.analyze.AnalyzedDecommissionNode) SubQueryResults(io.crate.planner.operators.SubQueryResults) DecommissionNodeRequest(io.crate.cluster.decommission.DecommissionNodeRequest) VisibleForTesting(io.crate.common.annotations.VisibleForTesting) OneRowActionListener(io.crate.execution.support.OneRowActionListener) Row1(io.crate.data.Row1) CoordinatorTxnCtx(io.crate.metadata.CoordinatorTxnCtx) Row1(io.crate.data.Row1) DecommissionNodeRequest(io.crate.cluster.decommission.DecommissionNodeRequest)

Example 15 with SubQueryResults

use of io.crate.planner.operators.SubQueryResults in project crate by crate.

the class SQLExecutor method planInternal.

private <T> T planInternal(AnalyzedStatement analyzedStatement, UUID jobId, int fetchSize, Row params) {
    RoutingProvider routingProvider = new RoutingProvider(random.nextInt(), emptyList());
    PlannerContext plannerContext = new PlannerContext(planner.currentClusterState(), routingProvider, jobId, coordinatorTxnCtx, nodeCtx, fetchSize, null);
    Plan plan = planner.plan(analyzedStatement, plannerContext);
    if (plan instanceof LogicalPlan) {
        return (T) ((LogicalPlan) plan).build(plannerContext, Set.of(), new ProjectionBuilder(nodeCtx), TopN.NO_LIMIT, 0, null, null, params, new SubQueryResults(emptyMap()) {

            @Override
            public Object getSafe(SelectSymbol key) {
                return Literal.of(key.valueType(), null);
            }
        });
    }
    return (T) plan;
}
Also used : SelectSymbol(io.crate.expression.symbol.SelectSymbol) RoutingProvider(io.crate.metadata.RoutingProvider) PlannerContext(io.crate.planner.PlannerContext) SubQueryResults(io.crate.planner.operators.SubQueryResults) LogicalPlan(io.crate.planner.operators.LogicalPlan) CreateBlobTablePlan(io.crate.planner.node.ddl.CreateBlobTablePlan) LogicalPlan(io.crate.planner.operators.LogicalPlan) Plan(io.crate.planner.Plan) CreateTablePlan(io.crate.planner.node.ddl.CreateTablePlan) ProjectionBuilder(io.crate.execution.dsl.projection.builder.ProjectionBuilder)

Aggregations

SubQueryResults (io.crate.planner.operators.SubQueryResults)36 Row (io.crate.data.Row)34 RowConsumer (io.crate.data.RowConsumer)33 PlannerContext (io.crate.planner.PlannerContext)32 DependencyCarrier (io.crate.planner.DependencyCarrier)31 Plan (io.crate.planner.Plan)31 Row1 (io.crate.data.Row1)30 OneRowActionListener (io.crate.execution.support.OneRowActionListener)30 SymbolEvaluator (io.crate.analyze.SymbolEvaluator)25 Symbol (io.crate.expression.symbol.Symbol)25 Function (java.util.function.Function)25 VisibleForTesting (io.crate.common.annotations.VisibleForTesting)20 NodeContext (io.crate.metadata.NodeContext)19 CoordinatorTxnCtx (io.crate.metadata.CoordinatorTxnCtx)18 Settings (org.elasticsearch.common.settings.Settings)17 List (java.util.List)13 DocTableInfo (io.crate.metadata.doc.DocTableInfo)11 ArrayList (java.util.ArrayList)10 Table (io.crate.sql.tree.Table)9 Lists2 (io.crate.common.collections.Lists2)8