memgraph / mage

MAGE - Memgraph Advanced Graph Extensions :crystal_ball:
Apache License 2.0
251 stars 25 forks source link

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

Open karmenrabar opened 10 months ago

karmenrabar commented 10 months ago

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_simplepaths' 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
  2. 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:

  1. MATCH (user:User) 
    with user
    CALL algo.all_simple_paths(user, user, [], 2) 
    YIELD path
    return path
  2. 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