use of io.crate.metadata.FunctionProvider in project crate by crate.
the class AbstractFunctionModule method register.
public void register(Signature signature, BiFunction<Signature, Signature, FunctionImplementation> factory) {
List<FunctionProvider> functions = functionImplementations.computeIfAbsent(signature.getName(), k -> new ArrayList<>());
var duplicate = functions.stream().filter(fr -> fr.getSignature().equals(signature)).findFirst();
if (duplicate.isPresent()) {
throw new IllegalStateException("A function already exists for signature = " + signature);
}
functions.add(new FunctionProvider(signature, factory));
}
use of io.crate.metadata.FunctionProvider in project crate by crate.
the class UserDefinedFunctionService method updateImplementations.
public void updateImplementations(String schema, Stream<UserDefinedFunctionMetadata> userDefinedFunctions, NodeContext nodeCtx) {
final Map<FunctionName, List<FunctionProvider>> implementations = new HashMap<>();
Iterator<UserDefinedFunctionMetadata> it = userDefinedFunctions.iterator();
while (it.hasNext()) {
UserDefinedFunctionMetadata udf = it.next();
FunctionProvider resolver = buildFunctionResolver(udf);
if (resolver == null) {
continue;
}
var functionName = new FunctionName(udf.schema(), udf.name());
var resolvers = implementations.computeIfAbsent(functionName, k -> new ArrayList<>());
resolvers.add(resolver);
}
nodeCtx.functions().registerUdfFunctionImplementationsForSchema(schema, implementations);
}
use of io.crate.metadata.FunctionProvider in project crate by crate.
the class PgFunctionIsVisibleFunctionTest method test_system_function_visibility.
@Test
public void test_system_function_visibility() {
assertEvaluate("pg_function_is_visible(0)", false);
assertEvaluate("pg_function_is_visible(-14)", false);
for (List<FunctionProvider> providers : sqlExpressions.nodeCtx.functions().functionResolvers().values()) {
for (FunctionProvider sysFunc : providers) {
Signature signature = sysFunc.getSignature();
Integer funcOid = OidHash.functionOid(signature);
assertEvaluate("pg_function_is_visible(" + funcOid + ")", true);
}
}
}
use of io.crate.metadata.FunctionProvider in project crate by crate.
the class PgGetFunctionResultFunctionTest method test_system_function_result_type_text_representation.
@Test
public void test_system_function_result_type_text_representation() {
for (List<FunctionProvider> providers : sqlExpressions.nodeCtx.functions().functionResolvers().values()) {
for (FunctionProvider sysFunc : providers) {
Signature signature = sysFunc.getSignature();
Integer funcOid = OidHash.functionOid(signature);
assertEvaluate("pg_get_function_result(" + funcOid + ")", signature.getReturnType().toString());
}
}
}
Aggregations