Search in sources :

Example 1 with ListFunctions

use of io.confluent.ksql.parser.tree.ListFunctions in project ksql by confluentinc.

the class ListFunctionsExecutor method execute.

public static StatementExecutorResponse execute(final ConfiguredStatement<ListFunctions> statement, final SessionProperties sessionProperties, final KsqlExecutionContext executionContext, final ServiceContext serviceContext) {
    final FunctionRegistry functionRegistry = executionContext.getMetaStore();
    final List<SimpleFunctionInfo> all = functionRegistry.listFunctions().stream().map(factory -> new SimpleFunctionInfo(factory.getName().toUpperCase(), FunctionType.SCALAR, factory.getMetadata().getCategory())).collect(Collectors.toList());
    functionRegistry.listTableFunctions().stream().map(factory -> new SimpleFunctionInfo(factory.getName().toUpperCase(), FunctionType.TABLE, factory.getMetadata().getCategory())).forEach(all::add);
    functionRegistry.listAggregateFunctions().stream().map(factory -> new SimpleFunctionInfo(factory.getName().toUpperCase(), FunctionType.AGGREGATE, factory.getMetadata().getCategory())).forEach(all::add);
    return StatementExecutorResponse.handled(Optional.of(new FunctionNameList(statement.getStatementText(), all)));
}
Also used : FunctionNameList(io.confluent.ksql.rest.entity.FunctionNameList) FunctionType(io.confluent.ksql.rest.entity.FunctionType) List(java.util.List) SessionProperties(io.confluent.ksql.rest.SessionProperties) KsqlExecutionContext(io.confluent.ksql.KsqlExecutionContext) FunctionRegistry(io.confluent.ksql.function.FunctionRegistry) ServiceContext(io.confluent.ksql.services.ServiceContext) ListFunctions(io.confluent.ksql.parser.tree.ListFunctions) Optional(java.util.Optional) ConfiguredStatement(io.confluent.ksql.statement.ConfiguredStatement) SimpleFunctionInfo(io.confluent.ksql.rest.entity.SimpleFunctionInfo) Collectors(java.util.stream.Collectors) FunctionRegistry(io.confluent.ksql.function.FunctionRegistry) FunctionNameList(io.confluent.ksql.rest.entity.FunctionNameList) SimpleFunctionInfo(io.confluent.ksql.rest.entity.SimpleFunctionInfo)

Aggregations

KsqlExecutionContext (io.confluent.ksql.KsqlExecutionContext)1 FunctionRegistry (io.confluent.ksql.function.FunctionRegistry)1 ListFunctions (io.confluent.ksql.parser.tree.ListFunctions)1 SessionProperties (io.confluent.ksql.rest.SessionProperties)1 FunctionNameList (io.confluent.ksql.rest.entity.FunctionNameList)1 FunctionType (io.confluent.ksql.rest.entity.FunctionType)1 SimpleFunctionInfo (io.confluent.ksql.rest.entity.SimpleFunctionInfo)1 ServiceContext (io.confluent.ksql.services.ServiceContext)1 ConfiguredStatement (io.confluent.ksql.statement.ConfiguredStatement)1 List (java.util.List)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1