Subqueries i.e. CALL { }

I’m trying to move from Neo4j to Memgraph. The following query uses a Neo4j specific feature that is not part of openCyper. I think they are called subqueries. Here’s a query that uses subqueries.

		UNWIND $batch as row
		MERGE (e:Entity {asset_id: row.asset_id, version: row.version, id: row.entity_id})
		WITH e, row
		CALL {
			WITH row
			WITH row WHERE row.has_parent=True AND row.parent <> ''
			MATCH (a:Entity {asset_id: row.asset_id, version: row.version, id: row.entity_id})
			SET a.fract_index = row.fract_index
		}
		WITH e, row
		CALL {
			WITH row
			WITH row WHERE row.has_parent=True AND row.parent = ''
			MATCH (a:Entity {asset_id: row.asset_id, version: row.version, id: row.entity_id})
			REMOVE a.fract_index
		}
		WITH e, row
		WITH node as e, row
		MERGE (e)<-[:ATTACHED_TO]-(c:Component {asset_id: row.asset_id, version: row.version, id: row.component_id})
		ON MATCH
			SET
				c.value = row.value
		ON CREATE
			SET
				c.value = row.value
		WITH e as child, row
		CALL {
		WITH child, row
		// conditional execution
		WITH child, row WHERE row.has_parent=True AND row.parent <> ''
		MERGE (e:Entity {asset_id: row.asset_id, version: row.version, id: row.parent})
		MERGE (e)<-[:CHILD_OF]-(child)
		}
		WITH child, row
		CALL {
			WITH child, row
			WITH child, row WHERE row.has_parent = True AND row.parent = ''
			MATCH (child:Entity {asset_id: row.asset_id, version: row.version, id: row.entity_id})-[r:CHILD_OF]->(:Entity)
				DELETE r
		}
		WITH child, row
		CALL {
		   WITH child, row
		   // conditional execution
		   WITH child, row WHERE row.referenced <> ''
		   MERGE (e:Entity {asset_id: row.asset_id, version: row.version, id: row.referenced})
		   MERGE (e)<-[:REFERS_TO]-(child)
		}

Is it possible to express this query in OpenCypher so that it works against Memgraph?

Hello @mburbidg,

Unfortunately, we can’t express this query currently, but I am happy to inform you that we are currently working on such subquery support.
Is this still a blocker for you to migrate to Memgraph?

Yes it blocks my exploration of moving from Neo4j to Memgraph. But if you’re working on it that is great. Do you have a timeframe for when this might be supported in Memgraph?

We opened an issue for this: Implement Cypher subqueries · Issue #784 · memgraph/memgraph · GitHub
There we will link a branch and you can track the progress.
We plan on including it in the 2.6.0 release, which as you can see is currently expected in three weeks.
Let me know how this sounds to you.

That sounds great. I will keep track of the progress.