use of io.crate.execution.dsl.phases.RoutedCollectPhase in project crate by crate.
the class DocLevelCollectTest method testCollectWithPartitionedColumns.
@Test
public void testCollectWithPartitionedColumns() throws Throwable {
RelationName relationName = new RelationName(Schemas.DOC_SCHEMA_NAME, PARTITIONED_TABLE_NAME);
TableInfo tableInfo = schemas.getTableInfo(relationName);
Routing routing = tableInfo.getRouting(clusterService().state(), new RoutingProvider(Randomness.get().nextInt(), Collections.emptyList()), WhereClause.MATCH_ALL, RoutingProvider.ShardSelection.ANY, SessionContext.systemSessionContext());
RoutedCollectPhase collectNode = getCollectNode(Arrays.asList(tableInfo.getReference(new ColumnIdent("id")), tableInfo.getReference(new ColumnIdent("date"))), routing, WhereClause.MATCH_ALL);
Bucket result = collect(collectNode);
assertThat(result, containsInAnyOrder(isRow(1, 0L), isRow(2, 1L)));
}
use of io.crate.execution.dsl.phases.RoutedCollectPhase in project crate by crate.
the class DocLevelCollectTest method testCollectDocLevelWhereClause.
@Test
public void testCollectDocLevelWhereClause() throws Throwable {
List<Symbol> arguments = Arrays.asList(testDocLevelReference, Literal.of(2));
EqOperator op = (EqOperator) functions.get(null, EqOperator.NAME, arguments, SearchPath.pathWithPGCatalogAndDoc());
List<Symbol> toCollect = Collections.singletonList(testDocLevelReference);
WhereClause whereClause = new WhereClause(new Function(op.signature(), arguments, EqOperator.RETURN_TYPE));
RoutedCollectPhase collectNode = getCollectNode(toCollect, whereClause);
Bucket result = collect(collectNode);
assertThat(result, contains(isRow(2)));
}
use of io.crate.execution.dsl.phases.RoutedCollectPhase 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.execution.dsl.phases.RoutedCollectPhase 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.execution.dsl.phases.RoutedCollectPhase in project crate by crate.
the class SystemCollectSourceTest method testReadIsolation.
@Test
public void testReadIsolation() throws Exception {
SystemCollectSource systemCollectSource = internalCluster().getDataNodeInstance(SystemCollectSource.class);
RoutedCollectPhase collectPhase = new RoutedCollectPhase(UUID.randomUUID(), 1, "collect", new Routing(Map.of()), RowGranularity.SHARD, List.of(), List.of(), WhereClause.MATCH_ALL.queryOrFallback(), DistributionInfo.DEFAULT_BROADCAST);
// No read isolation
List<String> noReadIsolationIterable = new ArrayList<>();
noReadIsolationIterable.add("a");
noReadIsolationIterable.add("b");
CoordinatorTxnCtx txnCtx = CoordinatorTxnCtx.systemTransactionContext();
Iterable<? extends Row> rows = systemCollectSource.toRowsIterableTransformation(collectPhase, txnCtx, unassignedShardRefResolver(), false).apply(noReadIsolationIterable);
assertThat(StreamSupport.stream(rows.spliterator(), false).count(), is(2L));
noReadIsolationIterable.add("c");
assertThat(StreamSupport.stream(rows.spliterator(), false).count(), is(3L));
// Read isolation
List<String> readIsolationIterable = new ArrayList<>();
readIsolationIterable.add("a");
readIsolationIterable.add("b");
rows = systemCollectSource.toRowsIterableTransformation(collectPhase, txnCtx, unassignedShardRefResolver(), true).apply(readIsolationIterable);
assertThat(StreamSupport.stream(rows.spliterator(), false).count(), is(2L));
readIsolationIterable.add("c");
assertThat(StreamSupport.stream(rows.spliterator(), false).count(), is(2L));
}
Aggregations