0

I am working on a custom query module on memgraph but cannot make it work properly. Whenever I try to execute my custom query module inside a CALL subquery, I get the following error message:

Query failed: Procedure 'test_module.create_node_from_map' did not yield all fields as required by its signature.

Here is a very simplified version of my work to highlight the issue I'm facing:

test_module.py:

This procedure just takes a Map (dict) and creates a new vertex containing every (key, value) as (property, property value).

import mgp

@mgp.write_proc
def create_node_from_map(context: mgp.ProcCtx, in_map: mgp.Map) -> mgp.Record(vertex=mgp.Vertex):
    new_vertex = context.graph.create_vertex()
    new_vertex.add_label(label="Human")
    for prop_name, prop_value in in_map.items():
        new_vertex.properties.set(property_name=prop_name, value=prop_value)
    return mgp.Record(vertex=new_vertex)

Cypher sample:

UNWIND [
  {
    name: "Erik",
    age: 99
  },
  {
    name: "Erika",
    age: 99
  }
] AS humans

CALL {
  WITH humans
  CALL test_module.create_node_from_map(humans) YIELD vertex
  RETURN vertex
}
RETURN vertex

Memgraph minimum log level is set to TRACE but there isn't more information inside the logs file.

However, when I remove the CALL block, the query executes properly and the procedure create_node_from_map works as intended:

CALL test_module.create_node_from_map(humans) YIELD vertex
RETURN vertex

Output:

Query Successful

#           vertex  
{: Human}   ID 27
{: Human}   ID 28

I couldn't find any information in the memgraph documentation or even on the web.

Does anyone have an explanation of this behavior? I'm currently stuck, any help would be very welcomed.

0 Answers0