Search in sources :

Example 21 with NoopClusterService

use of org.elasticsearch.test.cluster.NoopClusterService in project crate by crate.

the class JobContextServiceTest method prepare.

@Before
public void prepare() throws Exception {
    JobsLogs jobsLogs = new JobsLogs(() -> true);
    jobContextService = new JobContextService(Settings.EMPTY, new NoopClusterService(), jobsLogs);
}
Also used : JobsLogs(io.crate.operation.collect.stats.JobsLogs) NoopClusterService(org.elasticsearch.test.cluster.NoopClusterService) Before(org.junit.Before)

Example 22 with NoopClusterService

use of org.elasticsearch.test.cluster.NoopClusterService in project crate by crate.

the class NestedLoopConsumerTest method initPlanner.

@Before
public void initPlanner() throws Exception {
    ClusterService clusterService = new NoopClusterService();
    TableStats tableStats = getTableStats();
    e = SQLExecutor.builder(clusterService).enableDefaultTables().setTableStats(tableStats).addDocTable(emptyRoutingTable).build();
    Functions functions = e.functions();
    EvaluatingNormalizer normalizer = EvaluatingNormalizer.functionOnlyNormalizer(functions, ReplaceMode.COPY);
    plannerContext = new Planner.Context(e.planner, clusterService, UUID.randomUUID(), new ConsumingPlanner(clusterService, functions, tableStats), normalizer, new TransactionContext(SessionContext.SYSTEM_SESSION), 0, 0);
    consumer = new NestedLoopConsumer(clusterService, functions, tableStats);
}
Also used : NoopClusterService(org.elasticsearch.test.cluster.NoopClusterService) ClusterService(org.elasticsearch.cluster.ClusterService) EvaluatingNormalizer(io.crate.analyze.EvaluatingNormalizer) NoopClusterService(org.elasticsearch.test.cluster.NoopClusterService) Before(org.junit.Before)

Example 23 with NoopClusterService

use of org.elasticsearch.test.cluster.NoopClusterService in project crate by crate.

the class InsertFromValuesAnalyzerTest method init.

@Before
public void init() {
    SQLExecutor.Builder executorBuilder = SQLExecutor.builder(new NoopClusterService()).enableDefaultTables().addDocTable(testAliasTableInfo).addDocTable(nestedClusteredTableInfo);
    TableIdent notNullColumnTableIdent = new TableIdent(null, "not_null_column");
    TestingTableInfo.Builder notNullColumnTable = new TestingTableInfo.Builder(notNullColumnTableIdent, new Routing(ImmutableMap.of())).add("id", DataTypes.INTEGER, null).add("name", DataTypes.STRING, null, ColumnPolicy.DYNAMIC, IndexType.NOT_ANALYZED, false, false);
    executorBuilder.addDocTable(notNullColumnTable);
    TableIdent generatedColumnTableIdent = new TableIdent(null, "generated_column");
    TestingTableInfo.Builder generatedColumnTable = new TestingTableInfo.Builder(generatedColumnTableIdent, new Routing(ImmutableMap.<String, Map<String, List<Integer>>>of())).add("ts", DataTypes.TIMESTAMP, null).add("user", DataTypes.OBJECT, null).add("user", DataTypes.STRING, Arrays.asList("name")).addGeneratedColumn("day", DataTypes.TIMESTAMP, "date_trunc('day', ts)", false).addGeneratedColumn("name", DataTypes.STRING, "concat(user['name'], 'bar')", false);
    executorBuilder.addDocTable(generatedColumnTable);
    TableIdent generatedPkColumnTableIdent = new TableIdent(null, "generated_pk_column");
    TestingTableInfo.Builder generatedPkColumnTable = new TestingTableInfo.Builder(generatedPkColumnTableIdent, SHARD_ROUTING).add("serial_no", DataTypes.INTEGER, null).add("product_no", DataTypes.INTEGER, null).add("color", DataTypes.STRING, null).addGeneratedColumn("id", DataTypes.INTEGER, "serial_no + 1", false).addGeneratedColumn("id2", DataTypes.INTEGER, "product_no + 1", false).addPrimaryKey("id").addPrimaryKey("id2");
    executorBuilder.addDocTable(generatedPkColumnTable);
    TableIdent generatedClusteredByTableIdent = new TableIdent(null, "generated_clustered_by_column");
    TestingTableInfo.Builder clusteredByGeneratedTable = new TestingTableInfo.Builder(generatedClusteredByTableIdent, SHARD_ROUTING).add("serial_no", DataTypes.INTEGER, null).add("color", DataTypes.STRING, null).addGeneratedColumn("routing_col", DataTypes.INTEGER, "serial_no + 1", false).clusteredBy("routing_col");
    executorBuilder.addDocTable(clusteredByGeneratedTable);
    TableIdent generatedNestedClusteredByTableIdent = new TableIdent(null, "generated_nested_clustered_by");
    TestingTableInfo.Builder generatedNestedClusteredByInfo = new TestingTableInfo.Builder(generatedNestedClusteredByTableIdent, SHARD_ROUTING).add("o", DataTypes.OBJECT, null, ColumnPolicy.DYNAMIC).add("o", DataTypes.INTEGER, Arrays.asList("serial_number")).addGeneratedColumn("routing_col", DataTypes.INTEGER, "o['serial_number'] + 1", false).clusteredBy("routing_col");
    executorBuilder.addDocTable(generatedNestedClusteredByInfo);
    e = executorBuilder.build();
}
Also used : SQLExecutor(io.crate.testing.SQLExecutor) MapBuilder(org.elasticsearch.common.collect.MapBuilder) TableIdent(io.crate.metadata.TableIdent) NoopClusterService(org.elasticsearch.test.cluster.NoopClusterService) TestingTableInfo(io.crate.metadata.table.TestingTableInfo) Before(org.junit.Before)

Example 24 with NoopClusterService

use of org.elasticsearch.test.cluster.NoopClusterService in project crate by crate.

the class BlobTableAnalyzerTest method init.

@Before
public void init() throws Exception {
    NoopClusterService clusterService = new NoopClusterService();
    TableIdent myBlobsIdent = new TableIdent(BlobSchemaInfo.NAME, "blobs");
    TestingBlobTableInfo myBlobsTableInfo = TableDefinitions.createBlobTable(myBlobsIdent, clusterService);
    e = SQLExecutor.builder(clusterService).addBlobTable(myBlobsTableInfo).build();
}
Also used : TableIdent(io.crate.metadata.TableIdent) NoopClusterService(org.elasticsearch.test.cluster.NoopClusterService) Before(org.junit.Before)

Example 25 with NoopClusterService

use of org.elasticsearch.test.cluster.NoopClusterService in project crate by crate.

the class CreateDropRepositoryAnalyzerTest method init.

@Before
public void init() throws Exception {
    RepositoriesMetaData repositoriesMetaData = new RepositoriesMetaData(new RepositoryMetaData("my_repo", "fs", Settings.builder().put("location", "/tmp/my_repo").build()));
    ClusterState clusterState = ClusterState.builder(new ClusterName("testing")).metaData(MetaData.builder().putCustom(RepositoriesMetaData.TYPE, repositoriesMetaData)).build();
    NoopClusterService clusterService = new NoopClusterService(clusterState);
    e = SQLExecutor.builder(clusterService).build();
}
Also used : RepositoriesMetaData(org.elasticsearch.cluster.metadata.RepositoriesMetaData) ClusterState(org.elasticsearch.cluster.ClusterState) RepositoryMetaData(org.elasticsearch.cluster.metadata.RepositoryMetaData) ClusterName(org.elasticsearch.cluster.ClusterName) NoopClusterService(org.elasticsearch.test.cluster.NoopClusterService) Before(org.junit.Before)

Aggregations

NoopClusterService (org.elasticsearch.test.cluster.NoopClusterService)27 Before (org.junit.Before)19 ClusterService (org.elasticsearch.cluster.ClusterService)8 TableIdent (io.crate.metadata.TableIdent)7 Test (org.junit.Test)7 ClusterState (org.elasticsearch.cluster.ClusterState)6 CrateUnitTest (io.crate.test.integration.CrateUnitTest)5 TestingTableInfo (io.crate.metadata.table.TestingTableInfo)4 SQLExecutor (io.crate.testing.SQLExecutor)4 ClusterName (org.elasticsearch.cluster.ClusterName)4 MetaData (org.elasticsearch.cluster.metadata.MetaData)4 ImmutableMap (com.google.common.collect.ImmutableMap)3 JobContextService (io.crate.jobs.JobContextService)3 JobsLogs (io.crate.operation.collect.stats.JobsLogs)3 IndexMetaData (org.elasticsearch.cluster.metadata.IndexMetaData)3 TransportService (org.elasticsearch.transport.TransportService)3 PartitionName (io.crate.metadata.PartitionName)2 Routing (io.crate.metadata.Routing)2 TestingDocTableInfoFactory (io.crate.metadata.doc.TestingDocTableInfoFactory)2 RoutedCollectPhase (io.crate.planner.node.dql.RoutedCollectPhase)2