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.getMaskedStatementText(), all)));
  }
@Test
  public void shouldListFunctions() {

    // When:
    final FunctionNameList functionList = (FunctionNameList) CustomExecutors.LIST_FUNCTIONS.execute(
        engine.configure("LIST FUNCTIONS;"),
        mock(SessionProperties.class),
        engine.getEngine(),
        engine.getServiceContext()
    ).getEntity().orElseThrow(IllegalStateException::new);

    // Then:
    final Collection<SimpleFunctionInfo> functions = functionList.getFunctions();
    assertThat(functions, hasItems(
        new SimpleFunctionInfo("TEST_UDF_1", FunctionType.SCALAR,
            FunctionCategory.OTHER),
        new SimpleFunctionInfo("TOPK", FunctionType.AGGREGATE,
            FunctionCategory.AGGREGATE),
        new SimpleFunctionInfo("MAX", FunctionType.AGGREGATE,
            FunctionCategory.AGGREGATE),
        new SimpleFunctionInfo("TEST_UDTF1", FunctionType.TABLE, 
            FunctionCategory.TABLE),
        new SimpleFunctionInfo("TEST_UDTF2", FunctionType.TABLE,
            FunctionCategory.TABLE)
    ));
  }