use of io.crate.metadata.PartitionName in project crate by crate.
the class AlterTableAnalyzer method analyze.
public AlterTableAnalyzedStatement analyze(AlterTable node, Row parameters, String defaultSchema) {
Table table = node.table();
DocTableInfo tableInfo = schemas.getWritableTable(TableIdent.of(table, defaultSchema));
PartitionName partitionName = getPartitionName(table.partitionProperties(), tableInfo, parameters);
TableParameterInfo tableParameterInfo = getTableParameterInfo(table, tableInfo, partitionName);
TableParameter tableParameter = getTableParameter(node, parameters, tableParameterInfo);
maybeRaiseBlockedException(tableInfo, tableParameter.settings());
return new AlterTableAnalyzedStatement(tableInfo, partitionName, tableParameter, table.excludePartitions());
}
use of io.crate.metadata.PartitionName in project crate by crate.
the class PartitionPropertiesAnalyzerTest method testPartitionNameFromAssignmentWithBytesRef.
@Test
public void testPartitionNameFromAssignmentWithBytesRef() throws Exception {
DocTableInfo tableInfo = TestingTableInfo.builder(new TableIdent("doc", "users"), new Routing(ImmutableMap.<String, Map<String, List<Integer>>>of())).add("name", DataTypes.STRING, null, true).addPrimaryKey("name").build();
PartitionName partitionName = PartitionPropertiesAnalyzer.toPartitionName(tableInfo, Arrays.asList(new Assignment(new QualifiedNameReference(new QualifiedName("name")), new StringLiteral("foo"))), Row.EMPTY);
assertThat(partitionName.asIndexName(), is(".partitioned.users.0426crrf"));
}
use of io.crate.metadata.PartitionName in project crate by crate.
the class RefreshAnalyzerTest method testRefreshPartition.
@Test
public void testRefreshPartition() throws Exception {
PartitionName partition = new PartitionName("parted", Arrays.asList(new BytesRef("1395874800000")));
RefreshTableAnalyzedStatement analysis = e.analyze("refresh table parted PARTITION (date=1395874800000)");
assertThat(analysis.indexNames(), contains(".partitioned.parted.04732cpp6ks3ed1o60o30c1g"));
}
use of io.crate.metadata.PartitionName 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.PartitionName 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")));
}
Aggregations