Struggling with apoc.periodic.iterate and syntax

Hi

First time poster here.

I'm struggling with the syntax required for apoc.periodic.iterate. I'm using:

CALL apoc.periodic.iterate(
'LOAD CSV WITH HEADERS FROM $source_file AS row',
'WITH row.status as Status',
'RETURN Status LIMIT 10',
{batchSize:10000, iterateList:True, parallel:true})

and am getting the following error:

Neo.ClientError.Statement.SyntaxError: Procedure call does not provide the required number of arguments: got 4 expected 3.

Procedure apoc.periodic.iterate has signature: apoc.periodic.iterate(cypherIterate :: STRING?, cypherAction :: STRING?, config :: MAP?) :: batches :: INTEGER?, total :: INTEGER?, timeTaken :: INTEGER?, committedOperations :: INTEGER?, failedOperations :: INTEGER?, failedBatches :: INTEGER?, retries :: INTEGER?, errorMessages :: MAP?, batch :: MAP?, operations :: MAP?, wasTerminated :: BOOLEAN?, failedParams :: MAP?
meaning that it expects 3 arguments of type STRING?, STRING?, MAP?
Description: apoc.periodic.iterate('statement returning items', 'statement per item', {batchSize:1000,iterateList:true,parallel:false,params:{},concurrency:50,retries:0}) YIELD batches, total - run the second statement for each item returned by the first statement. Returns number of batches and total processed rows (line 13, column 1 (offset: 386))
"{batchSize:10000, iterateList:True, parallel:true})"

The query without apoc.periodic.iterate runs as expected:

LOAD CSV WITH HEADERS FROM $source_file AS row
WITH row.status as Status
RETURN Status LIMIT 10

I was following the advice in https://discourse.neo4j.com/t/struggling-with-apoc-periodic-iterate-in-a-big-query-from-python-code/3165 but to no avail.

Any help greatly appreciated.

Kind regards

The error tells you what you need to correct: you supplied 4 parameters to the call, but it only accepts 3. You have an extra query string parameter which isn't needed.

The first query string should be the driving query, that which will stream results, and then when batchSize results are taken from the stream then the second updating query will execute on the batch.

The other problem here is that your query doesn't update anything, and returns values instead. apoc.periodic.iterate() is meant as a means to update, not a means to return anything, and you won't have any way to get access to the returned values anyway.

Lastly, you are limiting your RETURN anyway, so you don't need apoc.periodic.iterate() at all. Just do this:

LOAD CSV WITH HEADERS FROM $source_file AS row
WITH row
LIMIT 10
RETURN row.status as Status

Thanks andrew.bowman - I didn't realise the underlying reason for the command and that I was not using it for the proper purpose.