use of io.crate.metadata.RelationName in project crate by crate.
the class TestingHelpers method refInfo.
public static Reference refInfo(String fqColumnName, DataType dataType, RowGranularity rowGranularity, String... nested) {
String[] parts = fqColumnName.split("\\.");
ReferenceIdent refIdent;
List<String> nestedParts = null;
if (nested.length > 0) {
nestedParts = Arrays.asList(nested);
}
switch(parts.length) {
case 2:
refIdent = new ReferenceIdent(new RelationName(Schemas.DOC_SCHEMA_NAME, parts[0]), parts[1], nestedParts);
break;
case 3:
refIdent = new ReferenceIdent(new RelationName(parts[0], parts[1]), parts[2], nestedParts);
break;
default:
throw new IllegalArgumentException("fqColumnName must contain <table>.<column> or <schema>.<table>.<column>");
}
return new Reference(refIdent, rowGranularity, dataType, 0, null);
}
use of io.crate.metadata.RelationName in project crate by crate.
the class InputFactoryTest method prepare.
@Before
public void prepare() throws Exception {
Map<RelationName, AnalyzedRelation> sources = T3.sources(List.of(T3.T1), clusterService);
DocTableRelation tr1 = (DocTableRelation) sources.get(T3.T1);
expressions = new SqlExpressions(sources, tr1);
factory = new InputFactory(expressions.nodeCtx);
}
use of io.crate.metadata.RelationName in project crate by crate.
the class GroupByPlannerTest method testGroupByOrderByPartitionedClolumn.
@Test
public void testGroupByOrderByPartitionedClolumn() throws Exception {
var e = SQLExecutor.builder(clusterService, 2, RandomizedTest.getRandom(), List.of()).addPartitionedTable("create table doc.clustered_parted (" + " id integer," + " date timestamp with time zone," + " city string" + ") clustered by (city) partitioned by (date) ", new PartitionName(new RelationName("doc", "clustered_parted"), singletonList("1395874800000")).asIndexName(), new PartitionName(new RelationName("doc", "clustered_parted"), singletonList("1395961200000")).asIndexName()).build();
Merge plan = e.plan("select date from clustered_parted group by date order by date");
Merge reduceMerge = (Merge) plan.subPlan();
OrderedTopNProjection topNProjection = (OrderedTopNProjection) reduceMerge.mergePhase().projections().get(1);
Symbol orderBy = topNProjection.orderBy().get(0);
assertThat(orderBy, instanceOf(InputColumn.class));
assertThat(orderBy.valueType(), is(DataTypes.TIMESTAMPZ));
}
use of io.crate.metadata.RelationName in project crate by crate.
the class DeletePartitionsTest method testIndexNameGeneration.
@Test
public void testIndexNameGeneration() throws Exception {
SQLExecutor e = SQLExecutor.builder(clusterService).addPartitionedTable(TableDefinitions.PARTED_PKS_TABLE_DEFINITION, new PartitionName(new RelationName("doc", "parted_pks"), singletonList("1395874800000")).asIndexName(), new PartitionName(new RelationName("doc", "parted_pks"), singletonList("1395961200000")).asIndexName()).build();
DeletePartitions plan = e.plan("delete from parted_pks where date = ?");
Object[] args1 = { "1395874800000" };
assertThat(plan.getIndices(txnCtx, e.nodeCtx, new RowN(args1), SubQueryResults.EMPTY), Matchers.containsInAnyOrder(".partitioned.parted_pks.04732cpp6ks3ed1o60o30c1g"));
Object[] args2 = { "1395961200000" };
assertThat(plan.getIndices(txnCtx, e.nodeCtx, new RowN(args2), SubQueryResults.EMPTY), Matchers.containsInAnyOrder(".partitioned.parted_pks.04732cpp6ksjcc9i60o30c1g"));
}
use of io.crate.metadata.RelationName in project crate by crate.
the class RestoreSnapshotPlanTest method testResolvePartitionedTableIndexFromSnapshot.
@Test
public void testResolvePartitionedTableIndexFromSnapshot() {
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(".partitioned.restoreme.046jcchm6krj4e1g60o30c0"), 0L, false)), context);
String template = templateName(Schemas.DOC_SCHEMA_NAME, "restoreme");
assertThat(context.resolvedIndices(), contains(template + "*"));
assertThat(context.resolvedTemplates(), contains(template));
}
Aggregations