use of io.crate.metadata.RelationName in project crate by crate.
the class SnapshotRestoreAnalyzerTest method testRestoreSinglePartitionToUnknownTable.
@Test
public void testRestoreSinglePartitionToUnknownTable() throws Exception {
BoundRestoreSnapshot statement = analyze(e, "RESTORE SNAPSHOT my_repo.my_snapshot TABLE unknown_parted PARTITION (date=123)");
PartitionName partitionName = new PartitionName(new RelationName("doc", "unknown_parted"), List.of("123"));
assertThat(statement.restoreTables().size(), is(1));
var table = statement.restoreTables().iterator().next();
assertThat(table.partitionName(), is(partitionName));
assertThat(table.tableIdent(), is(new RelationName(Schemas.DOC_SCHEMA_NAME, "unknown_parted")));
}
use of io.crate.metadata.RelationName in project crate by crate.
the class SnapshotRestoreAnalyzerTest method testRestoreSinglePartition.
@Test
public void testRestoreSinglePartition() throws Exception {
BoundRestoreSnapshot statement = analyze(e, "RESTORE SNAPSHOT my_repo.my_snapshot TABLE parted PARTITION (date=123)");
PartitionName partition = new PartitionName(new RelationName("doc", "parted"), List.of("123"));
assertThat(statement.restoreTables().size(), is(1));
var table = statement.restoreTables().iterator().next();
assertThat(table.partitionName(), is(partition));
assertThat(table.tableIdent(), is(new RelationName(Schemas.DOC_SCHEMA_NAME, "parted")));
assertThat(statement.includeTables(), is(true));
assertThat(statement.includeCustomMetadata(), is(false));
assertThat(statement.includeGlobalSettings(), is(false));
}
use of io.crate.metadata.RelationName in project crate by crate.
the class CopyAnalyzerTest method testCopyToWithPartitionIdentAndWhereClause.
@Test
public void testCopyToWithPartitionIdentAndWhereClause() throws Exception {
BoundCopyTo analysis = analyze("COPY parted PARTITION (date=1395874800000) WHERE id = 1 TO DIRECTORY '/tmp/foo'");
String parted = new PartitionName(new RelationName("doc", "parted"), Collections.singletonList("1395874800000")).asIndexName();
WhereClause where = analysis.whereClause();
assertThat(where.partitions(), contains(parted));
assertThat(where.query(), isFunction("op_="));
}
use of io.crate.metadata.RelationName in project crate by crate.
the class CopyAnalyzerTest method testCopyFromPartitionedTablePARTITIONKeywordValidArgs.
@Test
public void testCopyFromPartitionedTablePARTITIONKeywordValidArgs() throws Exception {
BoundCopyFrom analysis = analyze("COPY parted PARTITION (date=1395874800000) FROM '/some/distant/file.ext'");
String parted = new PartitionName(new RelationName("doc", "parted"), Collections.singletonList("1395874800000")).ident();
assertThat(analysis.partitionIdent(), equalTo(parted));
}
use of io.crate.metadata.RelationName in project crate by crate.
the class CopyAnalyzerTest method testCopyToFileWithPartitionClause.
@Test
public void testCopyToFileWithPartitionClause() throws Exception {
BoundCopyTo analysis = analyze("COPY parted PARTITION (date=1395874800000) TO DIRECTORY '/blah'");
String parted = new PartitionName(new RelationName("doc", "parted"), Collections.singletonList("1395874800000")).asIndexName();
assertThat(analysis.whereClause().partitions(), contains(parted));
}
Aggregations