Apoc.refactor.rename.type producing error java.lang.AssertionError: assertion failed

Hi everyone,

Am trying to rename a few thousand relationship types using apoc.refactor.rename.type but keep getting error and am wondering whether this is a bug but wanted to check here first before posting to Github.

This is the query am running ...

WITH collect(r) AS relationships
CALL apoc.refactor.rename.type('LABELED_AS', 'TAGGED_AS', relationships)
YIELD errorMessages AS eMessages 
RETURN eMessages

Which keeps producing following error ...

Neo.ClientError.Procedure.ProcedureCallFailed: Failed to invoke procedure `apoc.refactor.rename.type`: Caused by: java.lang.AssertionError: assertion failed

I did a bit of research but only found the following post which was about apoc.refactor.rename.label but it sounds similar so am now wondering if this is related ...

I ran EXPLAIN, see below, and also tried to run PROFILE but getting same error there.

I also tried to run this as apoc.periodic.iterate but then Neo4j desktop simply crashes ...

CALL apoc.periodic.iterate("MATCH ()-[r:LABELED_AS]->() RETURN r", "CALL apoc.refactor.rename.type('LABELED_AS', 'TAGGED_AS', r) YIELD errorMessages AS eMessages RETURN eMessages", {batchSize:1000, parallel:true})

I also tried to narrow down the MATCH phrase using below but same outcome ...

MATCH (n:Project)-[r:LABELED_AS]->()

Am running Neo4j 3.4.10 on Google Compute Engine with 4 vCPUs, 32 GB memory

Any ideas anyone? What am I doing wrong or is this a bug?

It's hard to tell. Why don't you delete all those edges and recreate them again? Something like this:

MATCH (a)-[r:LABELED_AS]->(b)
MERGE (a)-[:TAGGED_AS]->(b)

I guess I could create the new relationships first, check it's all ok and then delete the other ones! Good thinking, thanks!

Your cypher runs in a single transaction. So either it succeeds completely or it fails. Don’t worry about about partial failures. Just be careful if you have multiple edges of the same type between 2 nodes. You may delete them all but only create one if not careful.

1 Like

Update: I find wrapping the above into apoc.periodic.iterate works best and super fast i.e.

CALL apoc.periodic.iterate("
MATCH (n1)-[r:LABELED_AS]->(n2)
RETURN n1, r, n2", "
MERGE (n1)-[:TAGGED_AS]->(n2)
{batchSize:1000, iterateList:true, parallel:true})