use of io.crate.planner.node.dql.Collect in project crate by crate.
the class InsertPlannerTest method testInsertFromSubQueryESGet.
@Test
public void testInsertFromSubQueryESGet() {
Merge merge = e.plan("insert into users (date, id, name) (select date, id, name from users where id=1)");
Collect queryAndFetch = (Collect) merge.subPlan();
PKLookupPhase collectPhase = ((PKLookupPhase) 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.columnReferencesExclPartition().size(), is(3));
assertThat(projection.columnReferencesExclPartition().get(0).column().fqn(), is("date"));
assertThat(projection.columnReferencesExclPartition().get(1).column().fqn(), is("id"));
assertThat(projection.columnReferencesExclPartition().get(2).column().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.Collect in project crate by crate.
the class InsertPlannerTest method test_insert_from_group_by_uses_doc_values.
@Test
public void test_insert_from_group_by_uses_doc_values() throws Exception {
Merge merge = e.plan("insert into users (id) (select id from users group by 1)");
Collect collect = (Collect) merge.subPlan();
assertThat(collect.collectPhase().toCollect(), contains(SymbolMatchers.isReference("id")));
}
use of io.crate.planner.node.dql.Collect in project crate by crate.
the class InsertPlannerTest method testInsertFromSubQueryReduceOnCollectorGroupBy.
@Test
public void testInsertFromSubQueryReduceOnCollectorGroupBy() {
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(ColumnIndexWriterProjection.class)));
ColumnIndexWriterProjection columnIndexWriterProjection = (ColumnIndexWriterProjection) collectPhase.projections().get(1);
assertThat(columnIndexWriterProjection.columnReferencesExclPartition(), contains(isReference("id"), isReference("name")));
MergePhase mergePhase = merge.mergePhase();
assertThat(mergePhase.projections(), contains(instanceOf(MergeCountProjection.class)));
}
use of io.crate.planner.node.dql.Collect in project crate by crate.
the class InsertPlannerTest method testInsertFromSubQueryWithOffsetDoesTableWriteOnCollect.
@Test
public void testInsertFromSubQueryWithOffsetDoesTableWriteOnCollect() {
QueryThenFetch qtf = e.plan("insert into users (id, name) (select id, name from users offset 10)");
Merge merge = (Merge) qtf.subPlan();
// We can ignore the offset since SQL semantics don't promise a deterministic order without explicit order by clause
Collect collect = (Collect) merge.subPlan();
assertThat(collect.collectPhase().projections(), Matchers.empty());
assertThat(merge.mergePhase().projections(), contains(instanceOf(FetchProjection.class), instanceOf(ColumnIndexWriterProjection.class)));
}
use of io.crate.planner.node.dql.Collect in project crate by crate.
the class InsertPlannerTest method test_insert_from_sub_query_with_sys_tables_has_no_doc_lookup.
@Test
public void test_insert_from_sub_query_with_sys_tables_has_no_doc_lookup() {
Collect collect = e.plan("insert into users (id, name) (select oid, typname from pg_catalog.pg_type)");
assertThat(collect.collectPhase().toCollect(), contains(isReference("oid"), isReference("typname")));
}
Aggregations