use of io.crate.metadata.TableIdent in project crate by crate.
the class InsertFromSubQueryAnalyzerTest method initGeneratedColumnTable.
@Before
public void initGeneratedColumnTable() throws Exception {
SQLExecutor.Builder builder = SQLExecutor.builder(new NoopClusterService()).enableDefaultTables();
TableIdent usersGeneratedIdent = new TableIdent(null, "users_generated");
TestingTableInfo.Builder usersGenerated = new TestingTableInfo.Builder(usersGeneratedIdent, SHARD_ROUTING).add("id", DataTypes.LONG).add("firstname", DataTypes.STRING).add("lastname", DataTypes.STRING).addGeneratedColumn("name", DataTypes.STRING, "firstname || ' ' || lastname", false).addPrimaryKey("id");
builder.addDocTable(usersGenerated);
e = builder.build();
}
use of io.crate.metadata.TableIdent in project crate by crate.
the class SnapshotRestoreAnalyzerTest method testRestoreSinglePartition.
@Test
public void testRestoreSinglePartition() throws Exception {
RestoreSnapshotAnalyzedStatement statement = analyze("RESTORE SNAPSHOT my_repo.my_snapshot TABLE parted PARTITION (date=123)");
PartitionName partition = new PartitionName("parted", ImmutableList.of(new BytesRef("123")));
assertThat(statement.restoreTables().size(), is(1));
assertThat(statement.restoreTables().get(0).partitionName(), is(partition));
assertThat(statement.restoreTables().get(0).tableIdent(), is(new TableIdent(null, "parted")));
}
use of io.crate.metadata.TableIdent in project crate by crate.
the class SnapshotRestoreAnalyzerTest method testRestoreSinglePartitionToUnknownTable.
@Test
public void testRestoreSinglePartitionToUnknownTable() throws Exception {
RestoreSnapshotAnalyzedStatement statement = analyze("RESTORE SNAPSHOT my_repo.my_snapshot TABLE unknown_parted PARTITION (date=123)");
PartitionName partitionName = new PartitionName("unknown_parted", ImmutableList.of(new BytesRef("123")));
assertThat(statement.restoreTables().size(), is(1));
assertThat(statement.restoreTables().get(0).partitionName(), is(partitionName));
assertThat(statement.restoreTables().get(0).tableIdent(), is(new TableIdent(null, "unknown_parted")));
}
use of io.crate.metadata.TableIdent in project crate by crate.
the class SelectStatementAnalyzerTest method init.
@Before
public void init() throws Exception {
DocTableInfo fooUserTableInfo = TestingTableInfo.builder(new TableIdent("foo", "users"), SHARD_ROUTING).add("id", DataTypes.LONG, null).add("name", DataTypes.STRING, null).addPrimaryKey("id").build();
DocTableInfoFactory fooTableFactory = new TestingDocTableInfoFactory(ImmutableMap.of(fooUserTableInfo.ident(), fooUserTableInfo));
ClusterService clusterService = new NoopClusterService();
sqlExecutor = SQLExecutor.builder(clusterService).enableDefaultTables().addSchema(new DocSchemaInfo("foo", clusterService, fooTableFactory)).build();
}
use of io.crate.metadata.TableIdent in project crate by crate.
the class FetchContextTest method testSearcherIsAcquiredForShard.
@Test
public void testSearcherIsAcquiredForShard() throws Exception {
Routing routing = new Routing(TreeMapBuilder.<String, Map<String, List<Integer>>>newMapBuilder().put("dummy", TreeMapBuilder.<String, List<Integer>>newMapBuilder().put("i1", ImmutableList.of(1, 2)).map()).map());
IndexBaseVisitor ibv = new IndexBaseVisitor();
routing.walkLocations(ibv);
HashMultimap<TableIdent, String> tableIndices = HashMultimap.create();
tableIndices.put(new TableIdent(null, "i1"), "i1");
final FetchContext context = new FetchContext(new FetchPhase(1, null, ibv.build(), tableIndices, ImmutableList.of(createReference("i1", new ColumnIdent("x"), DataTypes.STRING))), "dummy", new SharedShardContexts(mock(IndicesService.class, RETURNS_MOCKS)), ImmutableList.of(routing));
context.prepare();
assertThat(context.searcher(1), Matchers.notNullValue());
assertThat(context.searcher(2), Matchers.notNullValue());
}
Aggregations