Following a Cypher query I found on TowardDataScience, I am attempting to load about 1 million rows from a CSV file while creating special relationships that contain information from specific columns in each row, e.g. making unique relationships for each row edge by concatenating properties/column values.
I am able to perform these two tasks independently but not together:
- LOAD CSV ... CALL { ... } IN TRANSACTION OF
- CALL apoc.create.relationship()
It does not like a CALL inside of a CALL, here is the query that fails, and the error shown below, the subquery works when I limit to some arbitrary number of rows, e.g. 1000 rows from the CSV, but will crash due to to memory issues if I try to load the entire CSV file at once:
LOAD CSV WITH HEADERS FROM "file:///FAF5_edges_2017.csv" AS row
CALL {
WITH row
MATCH (orig:Location {id: toInteger(row.orig)})
MATCH (dest:Location {id: toInteger(row.dest)})
CALL apoc.create.relationship(
orig,
'FLOW_' + toString(row.mode) + '_' + toString(row.sctg2),
{value: toFloat(row.value), tonnage: toFloat(row.tons)},
dest
) YIELD rel
RETURN count() as counter
} IN TRANSACTIONS OF 100 ROWS
RETURN count()
A query with 'CALL { ... } IN TRANSACTIONS' can only be executed in an implicit transaction, but tried to execute in an explicit transaction.
Thanks in advance for your help!