Search in sources :

Example 1 with UserDefinedFunctionService

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);
}
Also used : UserDefinedFunctionService(io.crate.expression.udf.UserDefinedFunctionService) ShardRowContext(io.crate.expression.reference.sys.shard.ShardRowContext) SysSchemaInfo(io.crate.metadata.sys.SysSchemaInfo) DocSchemaInfoFactory(io.crate.metadata.doc.DocSchemaInfoFactory) CrateSettings(io.crate.metadata.settings.CrateSettings) TestingDocTableInfoFactory(io.crate.metadata.doc.TestingDocTableInfoFactory) TestingHelpers.createNodeContext(io.crate.testing.TestingHelpers.createNodeContext) NodeContext(io.crate.metadata.NodeContext) Schemas(io.crate.metadata.Schemas) ShardReferenceResolver(io.crate.metadata.shard.ShardReferenceResolver) Before(org.junit.Before)

Example 2 with UserDefinedFunctionService

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);
    }
}
Also used : UserDefinedFunctionService(io.crate.expression.udf.UserDefinedFunctionService) Before(org.junit.Before)

Example 3 with UserDefinedFunctionService

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));
}
Also used : UserDefinedFunctionService(io.crate.expression.udf.UserDefinedFunctionService) Before(org.junit.Before)

Example 4 with UserDefinedFunctionService

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()));
}
Also used : UserDefinedFunctionService(io.crate.expression.udf.UserDefinedFunctionService) Input(io.crate.data.Input) UDFLanguage(io.crate.expression.udf.UDFLanguage) TransactionContext(io.crate.metadata.TransactionContext) NodeContext(io.crate.metadata.NodeContext) UserDefinedFunctionService(io.crate.expression.udf.UserDefinedFunctionService) Matchers(org.hamcrest.Matchers) Test(org.junit.Test) Signature(io.crate.metadata.functions.Signature) CrateDummyClusterServiceUnitTest(io.crate.test.integration.CrateDummyClusterServiceUnitTest) Index(org.elasticsearch.index.Index) UserDefinedFunctionsMetadata(io.crate.expression.udf.UserDefinedFunctionsMetadata) UserDefinedFunctionMetadata(io.crate.expression.udf.UserDefinedFunctionMetadata) Metadata(org.elasticsearch.cluster.metadata.Metadata) List(java.util.List) DataTypes(io.crate.types.DataTypes) Map(java.util.Map) Scalar(io.crate.metadata.Scalar) TestingHelpers.createNodeContext(io.crate.testing.TestingHelpers.createNodeContext) Nullable(javax.annotation.Nullable) SearchPath.pathWithPGCatalogAndDoc(io.crate.metadata.SearchPath.pathWithPGCatalogAndDoc) Before(org.junit.Before) ScriptException(javax.script.ScriptException) NodeContext(io.crate.metadata.NodeContext) TestingHelpers.createNodeContext(io.crate.testing.TestingHelpers.createNodeContext) UserDefinedFunctionMetadata(io.crate.expression.udf.UserDefinedFunctionMetadata) Scalar(io.crate.metadata.Scalar) ScriptException(javax.script.ScriptException) Input(io.crate.data.Input) TransactionContext(io.crate.metadata.TransactionContext) Signature(io.crate.metadata.functions.Signature) UDFLanguage(io.crate.expression.udf.UDFLanguage) Nullable(javax.annotation.Nullable) Before(org.junit.Before)

Example 5 with UserDefinedFunctionService

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);
}
Also used : UserDefinedFunctionService(io.crate.expression.udf.UserDefinedFunctionService) Before(org.junit.Before)

Aggregations

UserDefinedFunctionService (io.crate.expression.udf.UserDefinedFunctionService)5 Before (org.junit.Before)5 NodeContext (io.crate.metadata.NodeContext)2 TestingHelpers.createNodeContext (io.crate.testing.TestingHelpers.createNodeContext)2 Input (io.crate.data.Input)1 ShardRowContext (io.crate.expression.reference.sys.shard.ShardRowContext)1 UDFLanguage (io.crate.expression.udf.UDFLanguage)1 UserDefinedFunctionMetadata (io.crate.expression.udf.UserDefinedFunctionMetadata)1 UserDefinedFunctionsMetadata (io.crate.expression.udf.UserDefinedFunctionsMetadata)1 Scalar (io.crate.metadata.Scalar)1 Schemas (io.crate.metadata.Schemas)1 SearchPath.pathWithPGCatalogAndDoc (io.crate.metadata.SearchPath.pathWithPGCatalogAndDoc)1 TransactionContext (io.crate.metadata.TransactionContext)1 DocSchemaInfoFactory (io.crate.metadata.doc.DocSchemaInfoFactory)1 TestingDocTableInfoFactory (io.crate.metadata.doc.TestingDocTableInfoFactory)1 Signature (io.crate.metadata.functions.Signature)1 CrateSettings (io.crate.metadata.settings.CrateSettings)1 ShardReferenceResolver (io.crate.metadata.shard.ShardReferenceResolver)1 SysSchemaInfo (io.crate.metadata.sys.SysSchemaInfo)1 CrateDummyClusterServiceUnitTest (io.crate.test.integration.CrateDummyClusterServiceUnitTest)1