use of io.crate.metadata.FunctionName in project crate by crate.
the class UserDefinedFunctionsIntegrationTest method test_pg_function_is_visible.
@Test
public void test_pg_function_is_visible() throws Exception {
Signature signature = Signature.builder().kind(FunctionType.SCALAR).name(new FunctionName(Schemas.DOC_SCHEMA_NAME, "my_func")).argumentTypes(TypeSignature.parseTypeSignature("array(array(integer))"), TypeSignature.parseTypeSignature("integer"), TypeSignature.parseTypeSignature("text")).returnType(TypeSignature.parseTypeSignature("text")).build();
int functionOid = OidHash.functionOid(signature);
execute("select pg_function_is_visible(" + functionOid + ")");
assertThat(response.rows()[0][0], is(false));
execute("create function doc.my_func(array(array(integer)), integer, text) returns text language dummy_lang as '42'");
execute("select pg_function_is_visible(" + functionOid + ")");
assertThat(response.rows()[0][0], is(true));
execute("drop function doc.my_func(array(array(integer)), integer, text)");
execute("select pg_function_is_visible(" + functionOid + ")");
assertThat(response.rows()[0][0], is(false));
}
use of io.crate.metadata.FunctionName in project crate by crate.
the class JavascriptUserDefinedFunctionTest method registerUserDefinedFunction.
private void registerUserDefinedFunction(String name, DataType<?> returnType, List<DataType<?>> types, String definition) throws ScriptException {
UserDefinedFunctionMetadata udf = new UserDefinedFunctionMetadata(Schemas.DOC_SCHEMA_NAME, name, types.stream().map(FunctionArgumentDefinition::of).collect(Collectors.toList()), returnType, JS, definition);
String validation = udfService.getLanguage(JS).validate(udf);
if (validation == null) {
var functionName = new FunctionName(Schemas.DOC_SCHEMA_NAME, udf.name());
var resolvers = functionImplementations.computeIfAbsent(functionName, k -> new ArrayList<>());
resolvers.add(udfService.buildFunctionResolver(udf));
sqlExpressions.nodeCtx.functions().registerUdfFunctionImplementationsForSchema(Schemas.DOC_SCHEMA_NAME, functionImplementations);
} else {
throw new ScriptException(validation);
}
}
Aggregations