Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new function similar to apoc.periodic.iterate() but will raise an error when any batch fails #3547

Open
johnlinp opened this issue Apr 24, 2023 · 2 comments
Labels
core-functionality Adding new procedure, function or signature to APOC core enhancement extended-functionality

Comments

@johnlinp
Copy link

Feature description (Mandatory)

I'm using apoc.periodic.iterate() to iterate nodes and perform actions on each node. Sometimes, some of the actions would fail. However, when any action fails, the call to apoc.periodic.iterate() is still successful. Therefore, the queries following the call will still be executed. I find it inconvenient because I don't want the following queries to be executed when the call to apoc.periodic.iterate() fails. In addition to that, I'm using cypher-shell command to execute by queries, and I want cypher-shell to exit with a non-zero status code if any of the action fails in the call to apoc.periodic.iterate().

My proposal is to add a new function similar to apoc.periodic.iterate() and raise an error when any batch fails. That way, it can prevent the following queries to be executed and make cypher-shell exit with a non-zero status code when error occurs.

Considered alternatives

I know that I can check the output parameters failedOperations and failedBatches that returned from the call to apoc.periodic.iterate() to know if the call has failed or not, but I didn't find any way to raise an error with the help of these 2 output parameters.

How this feature can improve the project?

This new function is a general-purpose function, so I think many will find it helpful.

@lvijnck
Copy link

lvijnck commented Jul 15, 2024

yes please, I don't get how this does not happen.

Is there any workaround to understand whether any batch failed? I want to ensure that the resulting query fails.

@RobertoSannino
Copy link
Collaborator

The following behaviour, batching with error management, should be already covered by the subqueries error handling, check it out here:
https://neo4j.com/docs/cypher-manual/current/subqueries/subqueries-in-transactions/#error-behavior

@vga91 vga91 added extended-functionality core-functionality Adding new procedure, function or signature to APOC core labels Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-functionality Adding new procedure, function or signature to APOC core enhancement extended-functionality
Projects
None yet
Development

No branches or pull requests

5 participants