use of io.confluent.ksql.function.UserFunctionLoader in project ksql by confluentinc.
the class QueryAnalyzerFunctionalTest method shouldAnalyseTableFunctions.
@Test
public void shouldAnalyseTableFunctions() {
// We need to load udfs for this
final UserFunctionLoader loader = new UserFunctionLoader(functionRegistry, new File(""), Thread.currentThread().getContextClassLoader(), s -> false, Optional.empty(), true);
loader.load();
// Given:
final Query query = givenQuery("SELECT ID, EXPLODE(ARR1) FROM SENSOR_READINGS EMIT CHANGES;");
// When:
final Analysis analysis = queryAnalyzer.analyze(query, Optional.empty());
// Then:
assertThat(analysis.getTableFunctions(), hasSize(1));
assertThat(analysis.getTableFunctions().get(0).getName().text(), equalTo("EXPLODE"));
}
use of io.confluent.ksql.function.UserFunctionLoader in project ksql by confluentinc.
the class StandaloneExecutorFactory method create.
@VisibleForTesting
static StandaloneExecutor create(final Map<String, Object> properties, final String queriesFile, final String installDir, final Function<KsqlConfig, ServiceContext> serviceContextFactory, final BiFunction<String, KsqlConfig, ConfigStore> configStoreFactory, final Function<Supplier<Boolean>, VersionCheckerAgent> versionCheckerFactory, final StandaloneExecutorConstructor constructor, final MetricCollectors metricCollectors) {
final KsqlConfig baseConfig = new KsqlConfig(properties);
final ServiceContext serviceContext = serviceContextFactory.apply(baseConfig);
final String configTopicName = ReservedInternalTopics.configsTopic(baseConfig);
KsqlInternalTopicUtils.ensureTopic(configTopicName, baseConfig, serviceContext.getTopicClient());
final ConfigStore configStore = configStoreFactory.apply(configTopicName, baseConfig);
final KsqlConfig ksqlConfig = configStore.getKsqlConfig();
final ProcessingLogConfig processingLogConfig = new ProcessingLogConfig(properties);
final ProcessingLogContext processingLogContext = ProcessingLogContext.create(processingLogConfig);
final MutableFunctionRegistry functionRegistry = new InternalFunctionRegistry();
final KsqlEngine ksqlEngine = new KsqlEngine(serviceContext, processingLogContext, functionRegistry, ServiceInfo.create(ksqlConfig), new SequentialQueryIdGenerator(), ksqlConfig, Collections.emptyList(), metricCollectors);
final UserFunctionLoader udfLoader = UserFunctionLoader.newInstance(ksqlConfig, functionRegistry, installDir, metricCollectors.getMetrics());
final VersionCheckerAgent versionChecker = versionCheckerFactory.apply(ksqlEngine::hasActiveQueries);
return constructor.create(serviceContext, processingLogConfig, ksqlConfig, ksqlEngine, queriesFile, udfLoader, true, versionChecker, Injectors.NO_TOPIC_DELETE, metricCollectors);
}
Aggregations