CollAggregation { @UserAggregationFunction("apoc.agg.slice") @Description("apoc.agg.slice(value, start, length) - returns subset of non-null values, start is 0 based and length can be -1") public SliceFunction slice() { return new SliceFunction(); }  @UserAggregationFunction("apoc.agg.nth") @Description("apoc.agg.nth(value,offset) - returns value of nth row (or -1 for last)") NthFunction nthFunction(); @UserAggregationFunction("apoc.agg.first") @Description("apoc.agg.first(value) - returns first value") FirstFunction first(); @UserAggregationFunction("apoc.agg.last") @Description("apoc.agg.last(value) - returns last value") LastFunction last(); @UserAggregationFunction("apoc.agg.slice") @Description("apoc.agg.slice(value, start, length) - returns subset of non-null values, start is 0 based and length can be -1") SliceFunction slice();  }
@Test public void testSlice() throws Exception { testCall(db, "UNWIND RANGE(0,10) as value RETURN apoc.agg.slice(value,1,3) as slice", (row) -> { assertEquals(asList(1L,2L,3L), row.get("slice")); }); testCall(db, "UNWIND RANGE(0,3) as value RETURN apoc.agg.slice(value) as slice", (row) -> { assertEquals(asList(0L,1L,2L,3L), row.get("slice")); }); testCall(db, "UNWIND RANGE(0,3) as value RETURN apoc.agg.slice(value,2) as slice", (row) -> { assertEquals(asList(2L,3L), row.get("slice")); }); testCall(db, "UNWIND [null,41,null,42,null,43,null] as value RETURN apoc.agg.slice(value,1,3) as slice", (row) -> { assertEquals(asList(42L,43L), row.get("slice")); }); }