cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

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

christian
Node Clone

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 ...

MATCH ()-[r:LABELED_AS]->()
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?

1 ACCEPTED SOLUTION

shan
Graph Buddy

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)
DELETE r
MERGE (a)-[:TAGGED_AS]->(b)

View solution in original post

4 REPLIES 4

shan
Graph Buddy

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)
DELETE r
MERGE (a)-[:TAGGED_AS]->(b)

christian
Node Clone

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

shan
Graph Buddy

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.

christian
Node Clone

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", "
DELETE r 
MERGE (n1)-[:TAGGED_AS]->(n2)
RETURN *", 
{batchSize:1000, iterateList:true, parallel:true})