memgraph/mage

Bug when calling a procedure within a CALL { ... } sub-query

karmenrabar opened this issue · 0 comments

There appears to be a bug when calling any procedure within a CALL { ... } sub-query, in the context of a loop (where cardinality/rows are greater than 1). The error message received is: "Query failed: Procedure 'algo.all_simple_paths' did not yield all fields as required by its signature."

Example dataset:

CREATE (:User {id: 1, name: 'Alice'})
CREATE (:User {id: 2, name: 'Bob'})
CREATE (:User {id: 3, name: 'Charlie'})

CREATE (alice)-[:FOLLOWS]->(bob)
CREATE (bob)-[:FOLLOWS]->(charlie)

Example queries that return error message:

  1. When the procedure is called within the CALL { ... } sub-query and is part of a loop, the error is encountered.
    It may be connected to the fact that MATCH (user:User) RETURN user returns three rows.
MATCH (user:User) 
CALL {
  with user
CALL algo.all_simple_paths(user, user, [], 2) 
YIELD path
return path
}
return path
  1. Limiting the rows to 1 in the CALL{...} sub-query returns an error:
MATCH (user:User)  
with user 
CALL {
  with user  limit 1
CALL algo.all_simple_paths(user, user, [], 2) 
YIELD path
return path
}
return path

Example dataset that work well:

MATCH (user:User) 
  with user
CALL algo.all_simple_paths(user, user, [], 2) 
YIELD path
return path
  1. When limiting the rows to 1 in the initial MATCH, there is no issue when executing queries:
MATCH (user:User)  
with user limit 1  // reduce cardinality to 1
CALL {
  with user  
CALL algo.all_simple_paths(user, user, [], 2) 
YIELD path
return path
}
return path