use of io.crate.metadata.ReferenceIdent in project crate by crate.
the class HandlerSideLevelCollectTest method testClusterLevel.
@Test
public void testClusterLevel() throws Exception {
Schemas schemas = internalCluster().getInstance(Schemas.class);
TableInfo tableInfo = schemas.getTableInfo(new RelationName("sys", "cluster"));
Routing routing = tableInfo.getRouting(clusterService().state(), routingProvider, WhereClause.MATCH_ALL, RoutingProvider.ShardSelection.ANY, SessionContext.systemSessionContext());
Reference clusterNameRef = new Reference(new ReferenceIdent(SysClusterTableInfo.IDENT, new ColumnIdent("name")), RowGranularity.CLUSTER, DataTypes.STRING, 1, null);
RoutedCollectPhase collectNode = collectNode(routing, List.of(clusterNameRef), RowGranularity.CLUSTER);
Bucket result = collect(collectNode);
assertThat(result.size(), is(1));
assertThat(((String) result.iterator().next().get(0)), Matchers.startsWith("SUITE-"));
}
use of io.crate.metadata.ReferenceIdent in project crate by crate.
the class SystemCollectSourceTest method testOrderBySymbolsDoNotAppearTwiceInRows.
@Test
public void testOrderBySymbolsDoNotAppearTwiceInRows() throws Exception {
SystemCollectSource systemCollectSource = internalCluster().getDataNodeInstance(SystemCollectSource.class);
Reference shardId = new Reference(new ReferenceIdent(new RelationName("sys", "shards"), "id"), RowGranularity.SHARD, DataTypes.INTEGER, 0, null);
RoutedCollectPhase collectPhase = new RoutedCollectPhase(UUID.randomUUID(), 1, "collect", new Routing(Map.of()), RowGranularity.SHARD, Collections.singletonList(shardId), List.of(), WhereClause.MATCH_ALL.queryOrFallback(), DistributionInfo.DEFAULT_BROADCAST);
collectPhase.orderBy(new OrderBy(Collections.singletonList(shardId), new boolean[] { false }, new boolean[] { false }));
Iterable<? extends Row> rows = systemCollectSource.toRowsIterableTransformation(collectPhase, CoordinatorTxnCtx.systemTransactionContext(), unassignedShardRefResolver(), false).apply(Collections.singletonList(new UnassignedShard(1, "foo", mock(ClusterService.class), true, ShardRoutingState.UNASSIGNED)));
Row next = rows.iterator().next();
assertThat(next.numColumns(), is(1));
}
use of io.crate.metadata.ReferenceIdent in project crate by crate.
the class CountAggregationTest method test_count_on_object_with_not_null_sibling_not_use_DocValueAggregator.
@Test
public void test_count_on_object_with_not_null_sibling_not_use_DocValueAggregator() {
Reference notNullSibling = new Reference(new ReferenceIdent(null, new ColumnIdent("top_level_Integer")), RowGranularity.DOC, DataTypes.INTEGER, 0, null);
Reference countedObject = new Reference(new ReferenceIdent(null, new ColumnIdent("top_level_object")), RowGranularity.DOC, ObjectType.UNTYPED, 0, null);
DocTableInfo sourceTable = mock(DocTableInfo.class);
when(sourceTable.notNullColumns()).thenReturn(List.of(notNullSibling.column()));
when(sourceTable.getReference(eq(notNullSibling.column()))).thenReturn(notNullSibling);
assertHasDocValueAggregator(List.of(countedObject), sourceTable, null);
verify(sourceTable, times(1)).notNullColumns();
verify(sourceTable, times(0)).getReference(eq(notNullSibling.column()));
}
use of io.crate.metadata.ReferenceIdent in project crate by crate.
the class CountAggregationTest method test_count_on_object_with_not_null_siblings_child_not_use_DocValueAggregator.
@Test
public void test_count_on_object_with_not_null_siblings_child_not_use_DocValueAggregator() {
Reference notNullSibilingsChild = new Reference(new ReferenceIdent(null, new ColumnIdent("top_level_sibling", List.of("not_null_subcol"))), RowGranularity.DOC, DataTypes.STRING, 0, null);
Reference sibling = new // unused
Reference(new ReferenceIdent(null, new ColumnIdent("top_level_sibling")), RowGranularity.DOC, ObjectType.builder().setInnerType(notNullSibilingsChild.column().leafName(), notNullSibilingsChild.valueType()).build(), 0, null);
Reference countedObject = new Reference(new ReferenceIdent(null, new ColumnIdent("top_level_object")), RowGranularity.DOC, ObjectType.UNTYPED, 0, null);
DocTableInfo sourceTable = mock(DocTableInfo.class);
when(sourceTable.notNullColumns()).thenReturn(List.of(notNullSibilingsChild.column()));
when(sourceTable.getReference(eq(notNullSibilingsChild.column()))).thenReturn(notNullSibilingsChild);
assertHasDocValueAggregator(List.of(countedObject), sourceTable, null);
verify(sourceTable, times(1)).notNullColumns();
verify(sourceTable, times(0)).getReference(eq(notNullSibilingsChild.column()));
}
use of io.crate.metadata.ReferenceIdent in project crate by crate.
the class AbstractTableFunctionsTest method prepareFunctions.
@Before
public void prepareFunctions() {
DocTableRelation relation = mock(DocTableRelation.class);
RelationName relationName = new RelationName(null, "t");
when(relation.getField(any(ColumnIdent.class), any(Operation.class), any(Boolean.class))).thenReturn(new Reference(new ReferenceIdent(relationName, "name"), RowGranularity.NODE, DataTypes.STRING, 0, null));
sqlExpressions = new SqlExpressions(Map.of(relationName, relation));
}
Aggregations