use of io.crate.metadata.TableIdent in project crate by crate.
the class CreateBlobTableAnalyzer method analyze.
public CreateBlobTableAnalyzedStatement analyze(CreateBlobTable node, ParameterContext parameterContext) {
CreateBlobTableAnalyzedStatement statement = new CreateBlobTableAnalyzedStatement();
TableIdent tableIdent = BlobTableAnalyzer.tableToIdent(node.name());
statement.table(tableIdent, schemas);
int numShards;
Optional<ClusteredBy> clusteredBy = node.clusteredBy();
if (clusteredBy.isPresent()) {
numShards = numberOfShards.fromClusteredByClause(clusteredBy.get(), parameterContext.parameters());
} else {
numShards = numberOfShards.defaultNumberOfShards();
}
statement.tableParameter().settingsBuilder().put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, numShards);
// apply default in case it is not specified in the genericProperties,
// if it is it will get overwritten afterwards.
TablePropertiesAnalyzer.analyze(statement.tableParameter(), new BlobTableParameterInfo(), node.genericProperties(), parameterContext.parameters(), true);
return statement;
}
use of io.crate.metadata.TableIdent in project crate by crate.
the class DocTableInfoBuilderTest method testNoTableInfoFromOrphanedPartition.
@Test
public void testNoTableInfoFromOrphanedPartition() throws Exception {
String schemaName = randomSchema();
PartitionName partitionName = new PartitionName(schemaName, "test", Collections.singletonList(new BytesRef("boo")));
IndexMetaData.Builder indexMetaDataBuilder = IndexMetaData.builder(partitionName.asIndexName()).settings(Settings.builder().put("index.version.created", Version.CURRENT).build()).numberOfReplicas(0).numberOfShards(5).putMapping(Constants.DEFAULT_MAPPING_TYPE, "{" + " \"default\": {" + " \"properties\":{" + " \"id\": {" + " \"type\": \"integer\"," + " \"index\": \"not_analyzed\"" + " }" + " }" + " }" + "}");
MetaData metaData = MetaData.builder().put(indexMetaDataBuilder).build();
NoopClusterService clusterService = new NoopClusterService(ClusterState.builder(ClusterName.DEFAULT).metaData(metaData).build());
DocTableInfoBuilder builder = new DocTableInfoBuilder(functions, new TableIdent(schemaName, "test"), clusterService, new IndexNameExpressionResolver(Settings.EMPTY), mock(TransportPutIndexTemplateAction.class), executorService, false);
expectedException.expect(TableUnknownException.class);
expectedException.expectMessage(String.format(Locale.ENGLISH, "Table '%s.test' unknown", schemaName));
builder.build();
}
use of io.crate.metadata.TableIdent in project crate by crate.
the class SnapshotRestoreDDLDispatcherTest method testResolveUnknownTableFromSnapshot.
@Test
public void testResolveUnknownTableFromSnapshot() throws Exception {
expectedException.expect(TableUnknownException.class);
expectedException.expectMessage("Table 'doc.t1' unknown");
SnapshotRestoreDDLDispatcher.ResolveFromSnapshotActionListener.resolveIndexNameFromSnapshot(new TableIdent(null, "t1"), Collections.emptyList());
}
use of io.crate.metadata.TableIdent in project crate by crate.
the class SnapshotRestoreDDLDispatcherTest method testResolveMultiTablesIndexNamesFromSnapshot.
@Test
public void testResolveMultiTablesIndexNamesFromSnapshot() throws Exception {
List<RestoreSnapshotAnalyzedStatement.RestoreTableInfo> tables = Arrays.asList(new RestoreSnapshotAnalyzedStatement.RestoreTableInfo(new TableIdent(null, "my_table"), null), new RestoreSnapshotAnalyzedStatement.RestoreTableInfo(new TableIdent(null, "my_partitioned_table"), null));
List<SnapshotInfo> snapshots = Arrays.asList(new SnapshotInfo(new Snapshot("snapshot01", Collections.singletonList(".partitioned.my_partitioned_table.046jcchm6krj4e1g60o30c0"), 0)), new SnapshotInfo(new Snapshot("snapshot03", Collections.singletonList("my_table"), 0)));
CompletableFuture<List<String>> future = new CompletableFuture<>();
SnapshotRestoreDDLDispatcher.ResolveFromSnapshotActionListener actionListener = new SnapshotRestoreDDLDispatcher.ResolveFromSnapshotActionListener(future, tables, new HashSet<>());
// need to mock here as constructor is not accessible
GetSnapshotsResponse response = mock(GetSnapshotsResponse.class);
when(response.getSnapshots()).thenReturn(snapshots);
actionListener.onResponse(response);
assertThat(future.get(), containsInAnyOrder("my_table", PartitionName.templateName(null, "my_partitioned_table") + "*"));
}
use of io.crate.metadata.TableIdent in project crate by crate.
the class SnapshotRestoreDDLDispatcherTest method testResolveTableIndexWithIgnoreUnavailable.
@Test
public void testResolveTableIndexWithIgnoreUnavailable() throws Exception {
CompletableFuture<List<String>> f = SnapshotRestoreDDLDispatcher.resolveIndexNames(Collections.singletonList(new RestoreSnapshotAnalyzedStatement.RestoreTableInfo(new TableIdent(null, "my_table"), null)), true, null, "my_repo");
assertThat(f.get(), containsInAnyOrder("my_table", PartitionName.templateName(null, "my_table") + "*"));
}
Aggregations