use of io.crate.planner.node.dql.RoutedCollectPhase in project crate by crate.
the class InsertPlannerTest method testInsertFromSubQueryReduceOnCollectorGroupBy.
@Test
public void testInsertFromSubQueryReduceOnCollectorGroupBy() throws Exception {
Merge merge = e.plan("insert into users (id, name) (select id, arbitrary(name) from users group by id)");
Collect collect = (Collect) merge.subPlan();
RoutedCollectPhase collectPhase = ((RoutedCollectPhase) collect.collectPhase());
assertThat(collectPhase.projections(), contains(instanceOf(GroupProjection.class), instanceOf(EvalProjection.class), instanceOf(ColumnIndexWriterProjection.class)));
ColumnIndexWriterProjection columnIndexWriterProjection = (ColumnIndexWriterProjection) collectPhase.projections().get(2);
assertThat(columnIndexWriterProjection.columnReferences(), contains(isReference("id"), isReference("name")));
MergePhase mergePhase = merge.mergePhase();
assertThat(mergePhase.projections(), contains(instanceOf(MergeCountProjection.class)));
}
use of io.crate.planner.node.dql.RoutedCollectPhase in project crate by crate.
the class InsertPlannerTest method testInsertFromSubQueryWithoutLimit.
@Test
public void testInsertFromSubQueryWithoutLimit() throws Exception {
Merge planNode = e.plan("insert into users (id, name) (select id, name from users)");
Collect collect = (Collect) planNode.subPlan();
RoutedCollectPhase collectPhase = ((RoutedCollectPhase) collect.collectPhase());
assertThat(collectPhase.projections().size(), is(1));
assertThat(collectPhase.projections().get(0), instanceOf(ColumnIndexWriterProjection.class));
MergePhase localMergeNode = planNode.mergePhase();
assertThat(localMergeNode.projections().size(), is(1));
assertThat(localMergeNode.projections().get(0), instanceOf(MergeCountProjection.class));
}
use of io.crate.planner.node.dql.RoutedCollectPhase in project crate by crate.
the class InsertPlannerTest method testInsertFromSubQueryESGet.
@Test
public void testInsertFromSubQueryESGet() throws Exception {
// doesn't use ESGetNode but CollectNode.
// Round-trip to handler can be skipped by writing from the shards directly
Merge merge = e.plan("insert into users (date, id, name) (select date, id, name from users where id=1)");
Collect queryAndFetch = (Collect) merge.subPlan();
RoutedCollectPhase collectPhase = ((RoutedCollectPhase) queryAndFetch.collectPhase());
assertThat(collectPhase.projections().size(), is(1));
assertThat(collectPhase.projections().get(0), instanceOf(ColumnIndexWriterProjection.class));
ColumnIndexWriterProjection projection = (ColumnIndexWriterProjection) collectPhase.projections().get(0);
assertThat(projection.columnReferences().size(), is(3));
assertThat(projection.columnReferences().get(0).ident().columnIdent().fqn(), is("date"));
assertThat(projection.columnReferences().get(1).ident().columnIdent().fqn(), is("id"));
assertThat(projection.columnReferences().get(2).ident().columnIdent().fqn(), is("name"));
assertThat(((InputColumn) projection.ids().get(0)).index(), is(1));
assertThat(((InputColumn) projection.clusteredBy()).index(), is(1));
assertThat(projection.partitionedBySymbols().isEmpty(), is(true));
}
use of io.crate.planner.node.dql.RoutedCollectPhase in project crate by crate.
the class SystemCollectSourceTest method testOrderBySymbolsDoNotAppearTwiceInRows.
@Test
public void testOrderBySymbolsDoNotAppearTwiceInRows() throws Exception {
SystemCollectSource systemCollectSource = internalCluster().getInstance(SystemCollectSource.class);
Reference shardId = new Reference(new ReferenceIdent(new TableIdent("sys", "shards"), "id"), RowGranularity.SHARD, DataTypes.INTEGER);
RoutedCollectPhase collectPhase = new RoutedCollectPhase(UUID.randomUUID(), 1, "collect", new Routing(ImmutableMap.of()), RowGranularity.SHARD, Collections.singletonList(shardId), ImmutableList.of(), WhereClause.MATCH_ALL, DistributionInfo.DEFAULT_BROADCAST);
collectPhase.orderBy(new OrderBy(Collections.singletonList(shardId), new boolean[] { false }, new Boolean[] { null }));
Iterable<? extends Row> rows = systemCollectSource.toRowsIterableTransformation(collectPhase, false).apply(Collections.singletonList(new UnassignedShard(new ShardId("foo", 1), mock(ClusterService.class), true, ShardRoutingState.UNASSIGNED)));
Row next = rows.iterator().next();
assertThat(next.numColumns(), is(1));
}
use of io.crate.planner.node.dql.RoutedCollectPhase in project crate by crate.
the class BlobShardCollectorProviderTest method testReadIsolation.
@Test
public void testReadIsolation() throws Exception {
execute("create blob table b1 clustered into 1 shards with (number_of_replicas = 0)");
upload("b1", "foo");
upload("b1", "bar");
ensureGreen();
assertBusy(new Initializer());
RoutedCollectPhase collectPhase = new RoutedCollectPhase(UUID.randomUUID(), 1, "collect", new Routing(ImmutableMap.of()), RowGranularity.SHARD, ImmutableList.of(), ImmutableList.of(), WhereClause.MATCH_ALL, DistributionInfo.DEFAULT_BROADCAST);
// No read Isolation
Iterable<Row> iterable = getBlobRows(collectPhase, false);
assertThat(Iterables.size(iterable), is(2));
upload("b1", "newEntry1");
assertThat(Iterables.size(iterable), is(3));
// Read isolation
iterable = getBlobRows(collectPhase, true);
assertThat(Iterables.size(iterable), is(3));
upload("b1", "newEntry2");
assertThat(Iterables.size(iterable), is(3));
}
Aggregations