use of io.crate.execution.dsl.phases.RoutedCollectPhase in project crate by crate.
the class CopyToPlannerTest method testCopyToWithPartitionedGeneratedColumn.
@Test
public void testCopyToWithPartitionedGeneratedColumn() {
// test that generated partition column is NOT exported
Merge plan = plan("copy parted_generated to directory '/tmp'");
Collect innerPlan = (Collect) plan.subPlan();
RoutedCollectPhase node = ((RoutedCollectPhase) innerPlan.collectPhase());
WriterProjection projection = (WriterProjection) node.projections().get(0);
assertThat(projection.overwrites().size(), is(0));
}
use of io.crate.execution.dsl.phases.RoutedCollectPhase in project crate by crate.
the class UpdatePlannerTest method testUpdateOnEmptyPartitionedTable.
@Test
public void testUpdateOnEmptyPartitionedTable() throws Exception {
UpdatePlanner.Update update = e.plan("update empty_parted set name='Vogon lyric fan'");
Collect collect = (Collect) update.createExecutionPlan.create(e.getPlannerContext(clusterService.state()), Row.EMPTY, SubQueryResults.EMPTY);
assertThat(((RoutedCollectPhase) collect.collectPhase()).routing().nodes(), Matchers.emptyIterable());
}
use of io.crate.execution.dsl.phases.RoutedCollectPhase in project crate by crate.
the class GroupByScalarPlannerTest method testGroupByWithMultipleScalarPlan.
@Test
public void testGroupByWithMultipleScalarPlan() throws Exception {
Merge merge = e.plan("select abs(id + 1) from users group by id");
Collect collect = (Collect) merge.subPlan();
RoutedCollectPhase collectPhase = ((RoutedCollectPhase) collect.collectPhase());
assertEquals(DataTypes.LONG, collectPhase.outputTypes().get(0));
assertThat(collectPhase.maxRowGranularity(), is(RowGranularity.DOC));
assertThat(collectPhase.projections().size(), is(2));
assertThat(collectPhase.projections().get(0), instanceOf(GroupProjection.class));
assertThat(collectPhase.projections().get(0).requiredGranularity(), is(RowGranularity.SHARD));
assertThat(collectPhase.projections().get(1), instanceOf(EvalProjection.class));
assertThat(collectPhase.projections().get(1).outputs().get(0), isFunction("abs"));
assertThat(collectPhase.toCollect(), contains(isReference("id", DataTypes.LONG)));
GroupProjection groupProjection = (GroupProjection) collectPhase.projections().get(0);
assertThat(groupProjection.keys().get(0).valueType(), is(DataTypes.LONG));
MergePhase mergePhase = merge.mergePhase();
assertEquals(DataTypes.LONG, mergePhase.inputTypes().iterator().next());
assertEquals(DataTypes.LONG, mergePhase.outputTypes().get(0));
}
use of io.crate.execution.dsl.phases.RoutedCollectPhase in project crate by crate.
the class GroupByScalarPlannerTest method testGroupByScalarWithMultipleColumnArgumentsPlan.
@Test
public void testGroupByScalarWithMultipleColumnArgumentsPlan() throws Exception {
Merge merge = e.plan("select abs(id + other_id) from users group by id, other_id");
Merge subplan = (Merge) merge.subPlan();
Collect collect = (Collect) subplan.subPlan();
RoutedCollectPhase collectPhase = ((RoutedCollectPhase) collect.collectPhase());
assertThat(collectPhase.projections().size(), is(1));
assertThat(collectPhase.projections().get(0), instanceOf(GroupProjection.class));
assertThat(collectPhase.projections().get(0).requiredGranularity(), is(RowGranularity.SHARD));
assertThat(collectPhase.toCollect(), contains(isReference("id", DataTypes.LONG), isReference("other_id", DataTypes.LONG)));
GroupProjection groupProjection = (GroupProjection) collectPhase.projections().get(0);
assertThat(groupProjection.keys().size(), is(2));
assertThat(groupProjection.keys().get(0).valueType(), is(DataTypes.LONG));
assertThat(groupProjection.keys().get(1).valueType(), is(DataTypes.LONG));
MergePhase mergePhase = subplan.mergePhase();
assertThat(mergePhase.projections().size(), is(2));
assertThat(mergePhase.projections().get(0), instanceOf(GroupProjection.class));
assertThat(mergePhase.projections().get(1), instanceOf(EvalProjection.class));
assertThat(mergePhase.projections().get(1).outputs(), contains(isFunction("abs")));
}
use of io.crate.execution.dsl.phases.RoutedCollectPhase in project crate by crate.
the class InsertPlannerTest method testInsertFromQueryWithPartitionedColumn.
@Test
public void testInsertFromQueryWithPartitionedColumn() {
Merge planNode = e.plan("insert into users (id, date) (select id, date from parted_pks)");
Collect queryAndFetch = (Collect) planNode.subPlan();
RoutedCollectPhase collectPhase = ((RoutedCollectPhase) queryAndFetch.collectPhase());
List<Symbol> toCollect = collectPhase.toCollect();
assertThat(toCollect.size(), is(2));
assertThat(toCollect.get(0), isReference("_doc['id']"));
assertThat(toCollect.get(1), equalTo(new Reference(new ReferenceIdent(new RelationName(Schemas.DOC_SCHEMA_NAME, "parted_pks"), "date"), RowGranularity.PARTITION, DataTypes.TIMESTAMPZ, ColumnPolicy.DYNAMIC, IndexType.PLAIN, true, true, 3, null)));
}
Aggregations