Search in sources :

Example 1 with SessionSetting

use of io.crate.metadata.settings.session.SessionSetting in project crate by crate.

the class SetSessionPlan method executeOrFail.

@Override
public void executeOrFail(DependencyCarrier executor, PlannerContext plannerContext, RowConsumer consumer, Row params, SubQueryResults subQueryResults) throws Exception {
    Function<? super Symbol, Object> eval = x -> SymbolEvaluator.evaluate(plannerContext.transactionContext(), plannerContext.nodeContext(), x, params, subQueryResults);
    SessionContext sessionContext = plannerContext.transactionContext().sessionContext();
    Assignment<Symbol> assignment = settings.get(0);
    String settingName = eval.apply(assignment.columnName()).toString();
    validateSetting(settingName);
    SessionSetting<?> sessionSetting = sessionSettingRegistry.settings().get(settingName);
    if (sessionSetting == null) {
        LOGGER.info("SET SESSION STATEMENT WILL BE IGNORED: {}", settingName);
    } else {
        sessionSetting.apply(sessionContext, assignment.expressions(), eval);
    }
    consumer.accept(InMemoryBatchIterator.empty(SENTINEL), null);
}
Also used : CrateSettings(io.crate.metadata.settings.CrateSettings) SessionContext(io.crate.action.sql.SessionContext) SENTINEL(io.crate.data.SentinelRow.SENTINEL) InMemoryBatchIterator(io.crate.data.InMemoryBatchIterator) SessionSetting(io.crate.metadata.settings.session.SessionSetting) Function(java.util.function.Function) RowConsumer(io.crate.data.RowConsumer) DependencyCarrier(io.crate.planner.DependencyCarrier) Assignment(io.crate.sql.tree.Assignment) List(java.util.List) SymbolEvaluator(io.crate.analyze.SymbolEvaluator) Logger(org.apache.logging.log4j.Logger) 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) VisibleForTesting(io.crate.common.annotations.VisibleForTesting) LogManager(org.apache.logging.log4j.LogManager) SessionSettingRegistry(io.crate.metadata.settings.session.SessionSettingRegistry) Symbol(io.crate.expression.symbol.Symbol) SessionContext(io.crate.action.sql.SessionContext)

Aggregations

SessionContext (io.crate.action.sql.SessionContext)1 SymbolEvaluator (io.crate.analyze.SymbolEvaluator)1 VisibleForTesting (io.crate.common.annotations.VisibleForTesting)1 InMemoryBatchIterator (io.crate.data.InMemoryBatchIterator)1 Row (io.crate.data.Row)1 RowConsumer (io.crate.data.RowConsumer)1 SENTINEL (io.crate.data.SentinelRow.SENTINEL)1 Symbol (io.crate.expression.symbol.Symbol)1 CrateSettings (io.crate.metadata.settings.CrateSettings)1 SessionSetting (io.crate.metadata.settings.session.SessionSetting)1 SessionSettingRegistry (io.crate.metadata.settings.session.SessionSettingRegistry)1 DependencyCarrier (io.crate.planner.DependencyCarrier)1 Plan (io.crate.planner.Plan)1 PlannerContext (io.crate.planner.PlannerContext)1 SubQueryResults (io.crate.planner.operators.SubQueryResults)1 Assignment (io.crate.sql.tree.Assignment)1 List (java.util.List)1 Locale (java.util.Locale)1 Function (java.util.function.Function)1 LogManager (org.apache.logging.log4j.LogManager)1