use of io.crate.planner.node.dql.RoutedCollectPhase in project crate by crate.
the class GroupByPlannerTest method testGroupByWithAggregationStringLiteralArguments.
@Test
public void testGroupByWithAggregationStringLiteralArguments() {
Merge distributedGroupByMerge = e.plan("select count('foo'), name from users group by name");
RoutedCollectPhase collectPhase = ((DistributedGroupBy) distributedGroupByMerge.subPlan()).collectPhase();
assertThat(collectPhase.toCollect(), contains(isReference("name")));
GroupProjection groupProjection = (GroupProjection) collectPhase.projections().get(0);
assertThat(groupProjection.values().get(0), isAggregation("count"));
}
use of io.crate.planner.node.dql.RoutedCollectPhase in project crate by crate.
the class GroupByPlannerTest method testNonDistributedGroupByOnClusteredColumnSorted.
@Test
public void testNonDistributedGroupByOnClusteredColumnSorted() throws Exception {
Merge merge = e.plan("select count(*), id from users group by id order by 1 desc nulls last limit 20");
Collect collect = ((Collect) merge.subPlan());
RoutedCollectPhase collectPhase = ((RoutedCollectPhase) collect.collectPhase());
assertThat(collectPhase.projections().size(), is(2));
assertThat(collectPhase.projections().get(1), instanceOf(OrderedTopNProjection.class));
assertThat(((OrderedTopNProjection) collectPhase.projections().get(1)).orderBy().size(), is(1));
assertThat(collectPhase.projections().get(0).requiredGranularity(), is(RowGranularity.SHARD));
MergePhase mergePhase = merge.mergePhase();
assertThat(mergePhase.projections().size(), is(1));
assertThat(mergePhase.projections().get(0), instanceOf(TopNProjection.class));
PositionalOrderBy positionalOrderBy = mergePhase.orderByPositions();
assertThat(positionalOrderBy, notNullValue());
assertThat(positionalOrderBy.indices().length, is(1));
assertThat(positionalOrderBy.indices()[0], is(0));
assertThat(positionalOrderBy.reverseFlags()[0], is(true));
assertThat(positionalOrderBy.nullsFirst()[0], is(false));
}
use of io.crate.planner.node.dql.RoutedCollectPhase in project crate by crate.
the class GroupByPlannerTest method testNonDistributedGroupByAggregationsWrappedInScalar.
@Test
public void testNonDistributedGroupByAggregationsWrappedInScalar() throws Exception {
Merge planNode = e.plan("select (count(*) + 1), id from empty_parted group by id");
DistributedGroupBy distributedGroupBy = (DistributedGroupBy) planNode.subPlan();
RoutedCollectPhase collectPhase = distributedGroupBy.collectPhase();
assertThat(collectPhase.projections(), contains(instanceOf(GroupProjection.class)));
assertThat(collectPhase.projections().size(), is(1));
assertThat(collectPhase.projections().get(0), instanceOf(GroupProjection.class));
MergePhase mergePhase = planNode.mergePhase();
assertThat(mergePhase.projections().size(), is(0));
}
use of io.crate.planner.node.dql.RoutedCollectPhase in project crate by crate.
the class GroupByPlannerTest method testDistributedGroupByProjectionHasShardLevelGranularity.
@Test
public void testDistributedGroupByProjectionHasShardLevelGranularity() throws Exception {
Merge distributedGroupByMerge = e.plan("select count(*) from users group by name");
DistributedGroupBy distributedGroupBy = (DistributedGroupBy) distributedGroupByMerge.subPlan();
RoutedCollectPhase collectPhase = distributedGroupBy.collectPhase();
assertThat(collectPhase.projections().size(), is(1));
assertThat(collectPhase.projections().get(0), instanceOf(GroupProjection.class));
assertThat(collectPhase.projections().get(0).requiredGranularity(), is(RowGranularity.SHARD));
}
use of io.crate.planner.node.dql.RoutedCollectPhase in project crate by crate.
the class GroupByPlannerTest method testNonDistributedGroupByProjectionHasShardLevelGranularity.
@Test
public void testNonDistributedGroupByProjectionHasShardLevelGranularity() throws Exception {
Merge distributedGroupByMerge = e.plan("select count(distinct id), name from users" + " group by name order by count(distinct id)");
DistributedGroupBy distributedGroupBy = (DistributedGroupBy) distributedGroupByMerge.subPlan();
RoutedCollectPhase collectPhase = distributedGroupBy.collectPhase();
assertThat(collectPhase.projections().size(), is(1));
assertThat(collectPhase.projections().get(0), instanceOf(GroupProjection.class));
assertThat(collectPhase.projections().get(0).requiredGranularity(), is(RowGranularity.SHARD));
}
Aggregations