Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null results when calling scalar functions on unwound virtual nodes and relationships #13423

Open
egglessness opened this issue Mar 22, 2024 · 0 comments

Comments

@egglessness
Copy link

I'm trying to query Neo4j to get the graph schema in the D3.js JSON format ({"nodes": [], "edges": []}) but I'm encountering a strange behavior when I call scalar functions like labels(), startNode() or endNode() on unwound nodes and relationships.

I noticed this behavior when I run the following query:

CALL db.schema.visualization() YIELD nodes, relationships
UNWIND nodes AS n
UNWIND relationships AS r
RETURN {
    nodes: COLLECT(DISTINCT({key: elementId(n), attributes: {type: labels(n)}})),
    edges: COLLECT(DISTINCT({source: elementId(startNode(r)), target: elementId(endNode(r)), attributes: {type: type(r)}}))
}

If I run it, I get an unexpected graph: all the edges go from/to the same node, and all the nodes have no label

Returning the unwound nodes and relationships without any further processing works fine, so I suspect there is some issue on how scalar functions handle virtual nodes and relationships returned by db.schema.visualization().
Using apoc.meta.graph() leads to the same results.

Environment

  • Neo4j version: 5.14.0
  • Operating system: Debian 11.8 (Docker)
  • API/Driver: Neo4j Browser

Steps to reproduce

  1. Unwind nodes and get their labels:
CALL apoc.meta.graph() YIELD nodes, relationships
UNWIND nodes as n
RETURN labels(n)
  1. Unwind relationships and get starting and ending nodes:
CALL apoc.meta.graph() YIELD nodes, relationships
UNWIND relationships as r
RETURN elementId(startNode(r)), elementId(endNode(r))

Expected behavior

  1. Should return a list of lists of node labels
  2. Should return the IDs of the virtual nodes

Actual behavior

  1. Returns a list of empty lists
  2. Returns always the same start/end node for all the relationships
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants