use of io.crate.planner.node.dql.DistributedGroupBy 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.DistributedGroupBy in project crate by crate.
the class GroupByPlannerTest method testGroupByOrderByPartitionedClolumn.
@Test
public void testGroupByOrderByPartitionedClolumn() throws Exception {
Merge plan = e.plan("select date from clustered_parted group by date order by date");
DistributedGroupBy distributedGroupBy = (DistributedGroupBy) plan.subPlan();
OrderedTopNProjection topNProjection = (OrderedTopNProjection) distributedGroupBy.reducerMergeNode().projections().get(1);
Symbol orderBy = topNProjection.orderBy().get(0);
assertThat(orderBy, instanceOf(InputColumn.class));
assertThat(orderBy.valueType(), is(DataTypes.TIMESTAMP));
}
use of io.crate.planner.node.dql.DistributedGroupBy 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.DistributedGroupBy 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.DistributedGroupBy 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