Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
11-21-2022 02:51 AM
Hi everyone,
I have a problem with apoc.do.case but I do not understand where this come from.
I use apoc.do.case inside an apoc.trigger in this way:
CALL apoc.trigger.add('Trigger','UNWIND $createdNodes AS node
CALL apoc.do.case(
[
node:Mutation, reactkg.criticalEffect(node.name),
node:Sequence and reactkg.unassignedSequence(node.accession), reactkg.sequenceAlerts(5,6, node.accession),
],
"RETURN *", {node:node}) YIELD value
RETURN value', {phase:'afterAsync'});
Failed to invoke procedure `apoc.do.case`: Caused by: org.neo4j.exceptions.SyntaxException: Query cannot conclude with WITH (must be a RETURN clause, an update clause, a unit subquery call, or a procedure call with no YIELD) (line 1, column 2 (offset: 1)) " WITH $ `node` as `node`"
MATCH (v:Variant {pangoLineage: '"+csvLine[8]+"'})
MATCH mutations = (m:Mutation) where m.name in "+csvLine[5]+"
MATCH (l:Lab {name: '"+csvLine[7]+"'})
MATCH (p:Patient {cf: '"+csvLine[6]+"'})
MERGE (l)<-[:SEQUENCED_AT]-(s:Sequence {accession: '"+csvLine[2]+"', collectionDate: '"+csvLine[3]+"', isolate: '"+csvLine[4]+"', mutations: "+csvLine[5]+", host: '"+csvLine[6]+"'})-[:BELONGS_TO]->(v)
MERGE (p)<-[:AFFECTED]-(s)
FOREACH (n IN nodes(mutations) | MERGE (s)<-[:FOUND_IN]-(m))
11-21-2022 02:29 PM
As a note, I thought the queries in your case statement had to be strings. As such, should the syntax be:
CALL apoc.trigger.add('Trigger',
'
UNWIND $createdNodes AS node
CALL apoc.do.case(
[
node:Mutation, "reactkg.criticalEffect(node.name)",
node:Sequence and reactkg.unassignedSequence(node.accession), "reactkg.sequenceAlerts(5,6, node.accession)"
],
"RETURN *",
{node:node}) YIELD value
RETURN value
',
{phase:'afterAsync'});
11-22-2022 03:32 AM
Hi,
thank you for the suggestion but unfortunately those procedures already return strings themselves. In fact the creation of the node Alert related to the creation of a new node of label Mutation works fine, since the procedure:
reactkg.criticalEffect(node.name)
returns this string which creates the correct node Alert.
"CREATE (a:Alert{ description: 'New mutation with critical effect has been added', dateTime:datetime()})"
The procedure
reactkg.sequenceAlerts(5,6, node.accession)
does a very similar thing by returning strings of query of type CREATE.
However when adding nodes of type Sequence the log show the error
Failed to invoke procedure `apoc.do.case`: Caused by: org.neo4j.exceptions.SyntaxException: Query cannot conclude with WITH (must be a RETURN clause, an update clause, a unit subquery call, or a procedure call with no YIELD) (line 1, column 2 (offset: 1)) " WITH $ `node` as `node`"
Therefore I am not sure if this depends from a conflict of locks between the query that creates the node Sequence (shown in the original message) and the activation of the trigger or if it was because of a wrong syntax of the trigger.
Do you have any idea of what can it be? Thanks in advance!
All the sessions of the conference are now available online