use of io.crate.expression.udf.UDFLanguage in project crate by crate.
the class DocSchemaInfoTest method setup.
@Before
public void setup() throws Exception {
nodeCtx = createNodeContext();
udfService = new UserDefinedFunctionService(clusterService, nodeCtx);
udfService.registerLanguage(new UDFLanguage() {
@Override
public Scalar createFunctionImplementation(UserDefinedFunctionMetadata metadata, Signature signature) throws ScriptException {
String error = validate(metadata);
if (error != null) {
throw new ScriptException("this is not Burlesque");
}
return new Scalar<>() {
@Override
public Object evaluate(TransactionContext txnCtx, NodeContext nodeCtx, Input[] args) {
return null;
}
@Override
public Signature signature() {
return signature;
}
@Override
public Signature boundSignature() {
return signature;
}
};
}
@Override
@Nullable
public String validate(UserDefinedFunctionMetadata metadata) {
if (!metadata.definition().equals("\"Hello, World!\"Q")) {
return "this is not Burlesque";
}
return null;
}
@Override
public String name() {
return "burlesque";
}
});
docSchemaInfo = new DocSchemaInfo("doc", clusterService, nodeCtx, udfService, (ident, state) -> null, new TestingDocTableInfoFactory(Map.of()));
}
Aggregations