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

Inconsistent results when executing equivalent queries #617

Closed
YuanchengJiang opened this issue Apr 11, 2023 · 2 comments
Closed

Inconsistent results when executing equivalent queries #617

YuanchengJiang opened this issue Apr 11, 2023 · 2 comments
Labels

Comments

@YuanchengJiang
Copy link

Version: 2.13.0

Query 1:

MATCH ()-[]->(a), (a)-[]->() RETURN count(a)
// result: 9900

Query 2:

MATCH ()-[]->(a)-[]->() RETURN count(a)
// result: 998
@yjy44 yjy44 added the question label Apr 20, 2023
@samoscyberallenh
Copy link

This seems like a bug to me. Consider this test case:

postgres=# create graph test;
CREATE GRAPH
postgres=# set graph_path to test;
SET
postgres=# create vlabel person;
CREATE VLABEL
postgres=# create elabel knows;
CREATE ELABEL
postgres=# 
postgres=# create (fred:person {name: 'Fred'})-[:knows {name: 'Fred/Rob'}]->(rob:person {name: 'Rob'}), (rob)-[:knows {name: 'Rob/Sam'}]->(sam:person {name: 'Sam'}), (sam)-[:knows {name: 'Sam/Joe'}]->(joe:person {name: 'Joe'});
UPDATE 7
postgres=# match (a)-[e1]->(b)-[e2]->(c) return a.name as a, e1.name as e1, b.name as b, b.name as b, e2.name as e2, c.name as c;
   a    |     e1     |   b   |   b   |    e2     |   c   
--------+------------+-------+-------+-----------+-------
 "Fred" | "Fred/Rob" | "Rob" | "Rob" | "Rob/Sam" | "Sam"
 "Rob"  | "Rob/Sam"  | "Sam" | "Sam" | "Sam/Joe" | "Joe"
(2 rows)

OK, so far so good. That's equivalent to your Query 2. Those are the results I expected to see.

Now let's try to do something like your Query 1:

postgres=# match (a)-[e1]->(b), (b)-[e2]->(c) return a.name as a, e1.name as e1, b.name as b, b.name as b, e2.name as e2, c.name as c;
   a    |     e1     |   b    |   b    |     e2     |   c   
--------+------------+--------+--------+------------+-------
 "Rob"  | "Rob/Sam"  | "Fred" | "Fred" | "Fred/Rob" | "Rob"
 "Sam"  | "Sam/Joe"  | "Fred" | "Fred" | "Fred/Rob" | "Rob"
 "Fred" | "Fred/Rob" | "Rob"  | "Rob"  | "Rob/Sam"  | "Sam"
 "Sam"  | "Sam/Joe"  | "Rob"  | "Rob"  | "Rob/Sam"  | "Sam"
 "Fred" | "Fred/Rob" | "Sam"  | "Sam"  | "Sam/Joe"  | "Joe"
 "Rob"  | "Rob/Sam"  | "Sam"  | "Sam"  | "Sam/Joe"  | "Joe"
(6 rows)

Well, that's not good. Some of those edges are just not right. Specifically, these are wrong (the edges that are shown don't match the corresponding vertices):

 "Rob"  | "Rob/Sam"  | "Fred" | "Fred" | "Fred/Rob" | "Rob"
 "Sam"  | "Sam/Joe"  | "Fred" | "Fred" | "Fred/Rob" | "Rob"
 "Sam"  | "Sam/Joe"  | "Rob"  | "Rob"  | "Rob/Sam"  | "Sam"
 "Fred" | "Fred/Rob" | "Sam"  | "Sam"  | "Sam/Joe"  | "Joe"

Interestingly though, if you give "b" a label in the query it resolves the issue:

postgres=# match (a)-[e1]->(b:person), (b:person)-[e2]->(c) return a.name as a, e1.name as e1, b.name as b, b.name as b, e2.name as e2, c.name as c;
   a    |     e1     |   b   |   b   |    e2     |   c   
--------+------------+-------+-------+-----------+-------
 "Fred" | "Fred/Rob" | "Rob" | "Rob" | "Rob/Sam" | "Sam"
 "Rob"  | "Rob/Sam"  | "Sam" | "Sam" | "Sam/Joe" | "Joe"
(2 rows)

I'm using v2.13.0 here.

@emotionbug
Copy link
Contributor

emotionbug commented May 9, 2023

Will be fixed with #599 .
This patch included in v2.13.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants