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

Node matched too early in UNION on Enterprise #13436

Open
DominicWuest opened this issue Mar 29, 2024 · 0 comments
Open

Node matched too early in UNION on Enterprise #13436

DominicWuest opened this issue Mar 29, 2024 · 0 comments
Assignees

Comments

@DominicWuest
Copy link

DominicWuest commented Mar 29, 2024

I found a discrepancy when running two semantically equivalent queries against an empty database:


1:

RETURN 0 AS n1
	UNION
CALL {
  FOREACH ( n2 IN [] | FOREACH ( n3 IN [] | MERGE () ) )
} MATCH (y)
RETURN y AS n1
	UNION
CREATE ()
RETURN 0 AS n1

Produces:

╒═══╕
│n1 │
╞═══╡
│0  │
├───┤
│() │
└───┘

2:

FOREACH (n0 IN [] | FOREACH ( x IN [] | SET x = {} ) )
RETURN 0 AS n1
	UNION
CALL {
  FOREACH ( n2 IN [] | FOREACH ( n3 IN [] | MERGE () ) )
} MATCH (y)
RETURN y AS n1
	UNION
CREATE ()
RETURN 0 AS n1

Produces:

╒═══╕
│n1 │
╞═══╡
│0  │
└───┘

I believe the queries mentioned above are semantically equivalent and thus their result should be the same, since the first FOREACH is inconsequential, iterating over an empty list.

I encountered this issue when testing queries against the Neo4j 5.18.0 enterprise version in a Docker container running alpine v.3.

The query results are the same on Neo4j 5.13.0, but differ on Neo4j 5.14.0.
When testing the query against the community edition, the query results equal.
Additionally, when forcing the SLOTTED runtime, the results also equal.

It seems like the MATCH (y) clause mistakenly matches the nodes created in the last part of the UNION in the first query, as the returned node's labels match the ones of the node created there, if set.

Steps to reproduce

Run the aforementioned, semantically equivalent, queries against an empty database and observe that their results differ.

Expected behavior

The queries should result in the same behavior

Actual behavior

The query results differ

@jamthief jamthief self-assigned this Apr 10, 2024
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

3 participants