apoc.coll.partition

Function

apoc.coll.partition(coll LIST<ANY>, batchSize INTEGER) - partitions the original LIST<ANY> into a new LIST<ANY> of the given batch size. The final LIST<ANY> may be smaller than the given batch size.

Signature

apoc.coll.partition(values :: LIST<ANY>, batchSize :: INTEGER) :: LIST<ANY>

Input parameters

Name Type Default

values

LIST<ANY>

null

batchSize

INTEGER

null

Usage examples

The following partitions a list into sublists of size 2:

CALL apoc.coll.partition([1,2,3,4,5], 2);
Table 1. Results
Value

[1, 2]

[3, 4]

[5]