apoc.coll.partition

Function

apoc.coll.partition(coll [Any], batchSize Integer) - partitions the original list into sub-lists of the given batch size. The final list may be smaller than the given batch size.

Signature

apoc.coll.partition(values :: LIST? OF ANY?, batchSize :: INTEGER?) :: (LIST? OF ANY?)

Input parameters

Name Type Default

values

LIST? OF 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]