Search in sources :

Example 1 with CreateUserDefinedFunctionRequest

use of io.crate.expression.udf.CreateUserDefinedFunctionRequest in project crate by crate.

the class CreateFunctionPlan method executeOrFail.

@Override
public void executeOrFail(DependencyCarrier dependencies, 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);
    UserDefinedFunctionMetadata metadata = new UserDefinedFunctionMetadata(createFunction.schema(), createFunction.name(), createFunction.arguments(), createFunction.returnType(), StringType.INSTANCE.sanitizeValue(eval.apply(createFunction.language())), StringType.INSTANCE.sanitizeValue(eval.apply(createFunction.definition())));
    CreateUserDefinedFunctionRequest request = new CreateUserDefinedFunctionRequest(metadata, createFunction.replace());
    OneRowActionListener<AcknowledgedResponse> listener = new OneRowActionListener<>(consumer, r -> new Row1(1L));
    dependencies.createFunctionAction().execute(request, listener);
}
Also used : CreateUserDefinedFunctionRequest(io.crate.expression.udf.CreateUserDefinedFunctionRequest) StringType(io.crate.types.StringType) AnalyzedCreateFunction(io.crate.analyze.AnalyzedCreateFunction) AcknowledgedResponse(org.elasticsearch.action.support.master.AcknowledgedResponse) Function(java.util.function.Function) RowConsumer(io.crate.data.RowConsumer) DependencyCarrier(io.crate.planner.DependencyCarrier) UserDefinedFunctionMetadata(io.crate.expression.udf.UserDefinedFunctionMetadata) SymbolEvaluator(io.crate.analyze.SymbolEvaluator) Row(io.crate.data.Row) Symbol(io.crate.expression.symbol.Symbol) PlannerContext(io.crate.planner.PlannerContext) Plan(io.crate.planner.Plan) SubQueryResults(io.crate.planner.operators.SubQueryResults) OneRowActionListener(io.crate.execution.support.OneRowActionListener) Row1(io.crate.data.Row1) Row1(io.crate.data.Row1) OneRowActionListener(io.crate.execution.support.OneRowActionListener) UserDefinedFunctionMetadata(io.crate.expression.udf.UserDefinedFunctionMetadata) AcknowledgedResponse(org.elasticsearch.action.support.master.AcknowledgedResponse) CreateUserDefinedFunctionRequest(io.crate.expression.udf.CreateUserDefinedFunctionRequest)

Aggregations

AnalyzedCreateFunction (io.crate.analyze.AnalyzedCreateFunction)1 SymbolEvaluator (io.crate.analyze.SymbolEvaluator)1 Row (io.crate.data.Row)1 Row1 (io.crate.data.Row1)1 RowConsumer (io.crate.data.RowConsumer)1 OneRowActionListener (io.crate.execution.support.OneRowActionListener)1 Symbol (io.crate.expression.symbol.Symbol)1 CreateUserDefinedFunctionRequest (io.crate.expression.udf.CreateUserDefinedFunctionRequest)1 UserDefinedFunctionMetadata (io.crate.expression.udf.UserDefinedFunctionMetadata)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 StringType (io.crate.types.StringType)1 Function (java.util.function.Function)1 AcknowledgedResponse (org.elasticsearch.action.support.master.AcknowledgedResponse)1