use of io.crate.metadata.RelationName in project crate by crate.
the class RestoreSnapshotPlanTest method testResolveMultiTablesIndexNamesFromSnapshot.
@Test
public void testResolveMultiTablesIndexNamesFromSnapshot() {
List<BoundRestoreSnapshot.RestoreTableInfo> tables = List.of(new BoundRestoreSnapshot.RestoreTableInfo(new RelationName(Schemas.DOC_SCHEMA_NAME, "my_table"), null), new BoundRestoreSnapshot.RestoreTableInfo(new RelationName(Schemas.DOC_SCHEMA_NAME, "my_partitioned_table"), null));
List<SnapshotInfo> snapshots = List.of(new SnapshotInfo(new SnapshotId("snapshot01", UUID.randomUUID().toString()), List.of(".partitioned.my_partitioned_table.046jcchm6krj4e1g60o30c0"), 0, false), new SnapshotInfo(new SnapshotId("snapshot03", UUID.randomUUID().toString()), List.of("my_table"), 0, false));
var context = new RestoreSnapshotPlan.ResolveIndicesAndTemplatesContext();
RestoreSnapshotPlan.resolveTablesFromSnapshots(tables, snapshots, context);
assertThat(context.resolvedIndices(), containsInAnyOrder("my_table", templateName(Schemas.DOC_SCHEMA_NAME, "my_partitioned_table") + "*"));
assertThat(context.resolvedTemplates(), contains(templateName(Schemas.DOC_SCHEMA_NAME, "my_partitioned_table")));
}
use of io.crate.metadata.RelationName in project crate by crate.
the class RestoreSnapshotPlanTest method testResolveTableIndexFromSnapshot.
@Test
public void testResolveTableIndexFromSnapshot() {
var context = new RestoreSnapshotPlan.ResolveIndicesAndTemplatesContext();
RestoreSnapshotPlan.resolveTableFromSnapshots(new BoundRestoreSnapshot.RestoreTableInfo(new RelationName("custom", "restoreme"), null), List.of(new SnapshotInfo(new SnapshotId("snapshot01", UUID.randomUUID().toString()), List.of("custom.restoreme"), 0L, false)), context);
assertThat(context.resolvedIndices(), contains("custom.restoreme"));
assertThat(context.resolvedTemplates().size(), is(0));
}
use of io.crate.metadata.RelationName in project crate by crate.
the class RestoreSnapshotPlanTest method testResolveEmptyPartitionedTemplate.
@Test
public void testResolveEmptyPartitionedTemplate() {
var context = new RestoreSnapshotPlan.ResolveIndicesAndTemplatesContext();
RestoreSnapshotPlan.resolveTableFromSnapshots(new BoundRestoreSnapshot.RestoreTableInfo(new RelationName(Schemas.DOC_SCHEMA_NAME, "restoreme"), null), List.of(new SnapshotInfo(new SnapshotId("snapshot01", UUID.randomUUID().toString()), List.of(), 0L, false)), context);
assertThat(context.resolvedIndices().size(), is(0));
// If the snapshot doesn't contain any index which belongs to the table, it could be that the user
// restores an empty partitioned table. For that case we attempt to restore the table template.
assertThat(context.resolvedTemplates(), contains(templateName(Schemas.DOC_SCHEMA_NAME, "restoreme")));
}
use of io.crate.metadata.RelationName in project crate by crate.
the class HashJoinConditionSymbolsExtractorTest method testExtractFromNestedEqCondition.
@Test
public void testExtractFromNestedEqCondition() {
Symbol joinCondition = sqlExpressions.asSymbol("t1.x > t2.y and t1.a = t2.b and not(t1.i = t2.i)");
Map<RelationName, List<Symbol>> symbolsPerRelation = HashJoinConditionSymbolsExtractor.extract(joinCondition);
assertThat(symbolsPerRelation.get(tr1.relationName()), contains(isReference("a")));
assertThat(symbolsPerRelation.get(tr2.relationName()), contains(isReference("b")));
}
use of io.crate.metadata.RelationName in project crate by crate.
the class HashJoinConditionSymbolsExtractorTest method testExtractRelationsOfFunctionsWithLiterals.
@Test
public void testExtractRelationsOfFunctionsWithLiterals() {
Symbol joinCondition = sqlExpressions.asSymbol("t1.a = t2.b and t1.i + 1::int = t2.i and t2.y = 1::int + t1.i");
Map<RelationName, List<Symbol>> symbolsPerRelation = HashJoinConditionSymbolsExtractor.extract(joinCondition);
assertThat(symbolsPerRelation.get(tr1.relationName()), containsInAnyOrder(isReference("a"), isFunction(ArithmeticFunctions.Names.ADD, isReference("i"), isLiteral(1)), isFunction(ArithmeticFunctions.Names.ADD, isLiteral(1), isReference("i"))));
assertThat(symbolsPerRelation.get(tr2.relationName()), containsInAnyOrder(isReference("b"), isReference("i"), isReference("y")));
}
Aggregations