use of io.crate.execution.dsl.phases.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(Map.of()), RowGranularity.SHARD, List.of(), List.of(), WhereClause.MATCH_ALL.queryOrFallback(), DistributionInfo.DEFAULT_BROADCAST);
// No read Isolation
Iterable<Row> iterable = getBlobRows(collectPhase, false);
assertThat(StreamSupport.stream(iterable.spliterator(), false).count(), is(2L));
upload("b1", "newEntry1");
assertThat(StreamSupport.stream(iterable.spliterator(), false).count(), is(3L));
// Read isolation
iterable = getBlobRows(collectPhase, true);
assertThat(StreamSupport.stream(iterable.spliterator(), false).count(), is(3L));
upload("b1", "newEntry2");
assertThat(StreamSupport.stream(iterable.spliterator(), false).count(), is(3L));
}
use of io.crate.execution.dsl.phases.RoutedCollectPhase in project crate by crate.
the class InsertFromSubQueryPlannerTest method test_insert_from_subquery_with_order_by_symbols_match_collect_symbols.
@Test
public void test_insert_from_subquery_with_order_by_symbols_match_collect_symbols() {
// Ensures that order by symbols may also be rewritten to source lookup refs if collect symbols are rewritten
Merge localMerge = e.plan("insert into target (id, name) " + "select id, name from users order by id, name");
Collect collect = (Collect) localMerge.subPlan();
RoutedCollectPhase collectPhase = (RoutedCollectPhase) collect.collectPhase();
assertThat(collectPhase.orderBy().orderBySymbols(), is(collectPhase.toCollect()));
}
use of io.crate.execution.dsl.phases.RoutedCollectPhase in project crate by crate.
the class RoutedCollectPhaseTest method testStreaming.
@Test
public void testStreaming() throws Exception {
List<Symbol> toCollect = List.of(Literal.of(DataTypes.STRING, null));
UUID jobId = UUID.randomUUID();
RoutedCollectPhase cn = new RoutedCollectPhase(jobId, 0, "cn", new Routing(Map.of()), RowGranularity.DOC, toCollect, List.of(), WhereClause.MATCH_ALL.queryOrFallback(), DistributionInfo.DEFAULT_MODULO);
BytesStreamOutput out = new BytesStreamOutput();
cn.writeTo(out);
StreamInput in = out.bytes().streamInput();
RoutedCollectPhase cn2 = new RoutedCollectPhase(in);
assertThat(cn, equalTo(cn2));
assertThat(cn.toCollect(), is(cn2.toCollect()));
assertThat(cn.nodeIds(), is(cn2.nodeIds()));
assertThat(cn.jobId(), is(cn2.jobId()));
assertThat(cn.phaseId(), is(cn2.phaseId()));
assertThat(cn.maxRowGranularity(), is(cn2.maxRowGranularity()));
assertThat(cn.distributionInfo(), is(cn2.distributionInfo()));
}
use of io.crate.execution.dsl.phases.RoutedCollectPhase in project crate by crate.
the class GroupByPlannerTest method testGroupByHavingNonDistributed.
@Test
public void testGroupByHavingNonDistributed() throws Exception {
var e = SQLExecutor.builder(clusterService, 2, RandomizedTest.getRandom(), List.of()).addTable(TableDefinitions.USER_TABLE_DEFINITION).build();
Merge merge = e.plan("select id from users group by id having id > 0");
Collect collect = (Collect) merge.subPlan();
RoutedCollectPhase collectPhase = ((RoutedCollectPhase) collect.collectPhase());
assertThat(collectPhase.where(), isSQL("(doc.users.id > 0::bigint)"));
assertThat(collectPhase.projections(), contains(instanceOf(GroupProjection.class)));
MergePhase localMergeNode = merge.mergePhase();
assertThat(localMergeNode.projections(), empty());
}
use of io.crate.execution.dsl.phases.RoutedCollectPhase in project crate by crate.
the class GroupByPlannerTest method testNoDistributedGroupByOnAllPrimaryKeys.
@Test
public void testNoDistributedGroupByOnAllPrimaryKeys() throws Exception {
var e = SQLExecutor.builder(clusterService, 2, RandomizedTest.getRandom(), List.of()).addPartitionedTable("create table doc.empty_parted (" + " id integer primary key," + " date timestamp with time zone primary key" + ") clustered by (id) partitioned by (date)").build();
Collect collect = e.plan("select count(*), id, date from empty_parted group by id, date limit 20");
RoutedCollectPhase collectPhase = ((RoutedCollectPhase) collect.collectPhase());
assertThat(collectPhase.projections().size(), is(3));
assertThat(collectPhase.projections().get(0), instanceOf(GroupProjection.class));
assertThat(collectPhase.projections().get(0).requiredGranularity(), is(RowGranularity.SHARD));
assertThat(collectPhase.projections().get(1), instanceOf(TopNProjection.class));
assertThat(collectPhase.projections().get(2), instanceOf(EvalProjection.class));
}
Aggregations