use of io.crate.expression.udf.UserDefinedFunctionService in project crate by crate.
the class SysShardsExpressionsTest method prepare.
@Before
public void prepare() {
NodeContext nodeCtx = createNodeContext();
indexShard = mockIndexShard();
CrateSettings crateSettings = new CrateSettings(clusterService, clusterService.getSettings());
UserDefinedFunctionService udfService = new UserDefinedFunctionService(clusterService, nodeCtx);
schemas = new Schemas(Map.of("sys", new SysSchemaInfo(this.clusterService, crateSettings)), clusterService, new DocSchemaInfoFactory(new TestingDocTableInfoFactory(Collections.emptyMap()), (ident, state) -> null, nodeCtx, udfService));
resolver = new ShardReferenceResolver(schemas, new ShardRowContext(indexShard, clusterService));
sysShards = schemas.getTableInfo(SysShardsTableInfo.IDENT);
}
use of io.crate.expression.udf.UserDefinedFunctionService in project crate by crate.
the class SnapshotRestoreIntegrationTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
defaultRepositoryLocation = TEMPORARY_FOLDER.newFolder();
execute("CREATE REPOSITORY " + REPOSITORY_NAME + " TYPE \"fs\" with (location=?, compress=True)", new Object[] { defaultRepositoryLocation.getAbsolutePath() });
assertThat(response.rowCount(), is(1L));
execute("CREATE REPOSITORY my_repo_ro TYPE \"fs\" with (location=?, compress=true, readonly=true)", new Object[] { defaultRepositoryLocation.getAbsolutePath() });
var dummyLang = new UserDefinedFunctionsIntegrationTest.DummyLang();
Iterable<UserDefinedFunctionService> udfServices = internalCluster().getInstances(UserDefinedFunctionService.class);
for (UserDefinedFunctionService udfService : udfServices) {
udfService.registerLanguage(dummyLang);
}
}
use of io.crate.expression.udf.UserDefinedFunctionService in project crate by crate.
the class JavascriptUserDefinedFunctionTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
udfService = new UserDefinedFunctionService(mock(ClusterService.class), sqlExpressions.nodeCtx);
udfService.registerLanguage(new JavaScriptLanguage(udfService));
}
use of io.crate.expression.udf.UserDefinedFunctionService 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()));
}
use of io.crate.expression.udf.UserDefinedFunctionService in project crate by crate.
the class DocIndexMetadataTest method setupUdfService.
@Before
public void setupUdfService() {
nodeCtx = createNodeContext();
udfService = new UserDefinedFunctionService(clusterService, nodeCtx);
}
Aggregations