apoc.coll.partition

This is both a function and a procedure.

Function Details

Details

Syntax

apoc.coll.partition(coll, batchSize)

Description

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.

Arguments

Name

Type

Description

coll

LIST<ANY>

The list to partition into smaller sublists.

batchSize

INTEGER

The max size of each partitioned sublist.

Returns

LIST<ANY>

Procedure Details

Details

Syntax

apoc.coll.partition(coll, batchSize) :: (value)

Description

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.

Input arguments

Name

Type

Description

coll

LIST<ANY>

The list to partition into smaller sublists.

batchSize

INTEGER

The max size of each partitioned sublist.

Return arguments

Name

Type

Description

value

LIST<ANY>

The partitioned list.

Usage examples

The following partitions a list into sublists of size 2:

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

[1, 2]

[3, 4]

[5]