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

Two below match queries get different results #4936

Closed
yixinglu opened this issue Nov 25, 2022 · 2 comments
Closed

Two below match queries get different results #4936

yixinglu opened this issue Nov 25, 2022 · 2 comments
Assignees
Labels
affects/none PR/issue: this bug affects none version. process/done Process of bug severity/none Severity of bug type/bug Type: something is unexpected
Milestone

Comments

@yixinglu
Copy link
Contributor

yixinglu commented Nov 25, 2022

following queries get the same results in sf100 dataset:

MATCH (person:Person)-[:KNOWS]-(friend)
WHERE id(person) == "p-65504"
WITH person, collect(id(friend)) AS friends
MATCH (person:Person)-[:KNOWS*2]-(friend)-[:IS_LOCATED_IN]->(city:Place)
WHERE id(friend) != "p-65504" AND id(friend) NOT IN friends
WITH person, city, friend, datetime(friend.Person.birthday) as birthday
WHERE (birthday.month==5 AND birthday.day>=21) OR
        (birthday.month==(5%12)+1 AND birthday.day<22)
RETURN DISTINCT friend, city, person
//-------
MATCH (person:Person)-[:KNOWS*2]-(friend)-[:IS_LOCATED_IN]->(city:Place)
WHERE id(person) == "p-65504" AND id(friend) != "p-65504" AND NOT (person)-[:KNOWS]-(friend)
WITH person, city, friend, datetime(friend.Person.birthday) as birthday
WHERE (birthday.month==5 AND birthday.day>=21) OR
        (birthday.month==(5%12)+1 AND birthday.day<22)
RETURN DISTINCT friend, city, person

But I get different results in below match statements:

MATCH (person:Person)-[:KNOWS]-(friend)
WHERE id(person) == "p-65504"
WITH person, collect(id(friend)) AS friends
MATCH (person:Person)-[:KNOWS*2]-(friend)-[:IS_LOCATED_IN]->(city:Place)
WHERE id(friend) != "p-65504" AND id(friend) NOT IN friends
WITH person, city, friend, datetime(friend.Person.birthday) as birthday
WHERE (birthday.month==5 AND birthday.day>=21) OR
        (birthday.month==(5%12)+1 AND birthday.day<22)
WITH DISTINCT friend, city, person
OPTIONAL MATCH (friend)<-[:POST_HAS_CREATOR]-(post:Post)
OPTIONAL MATCH (person)-[:HAS_INTEREST]->()<-[:HAS_TAG]-(post)
RETURN friend, city
//--------
MATCH (person:Person)-[:KNOWS*2]-(friend)-[:IS_LOCATED_IN]->(city:Place)
WHERE id(person) == "p-65504" AND id(friend) != "p-65504" AND NOT (person)-[:KNOWS]-(friend)
WITH person, city, friend, datetime(friend.Person.birthday) as birthday
WHERE (birthday.month==5 AND birthday.day>=21) OR
        (birthday.month==(5%12)+1 AND birthday.day<22)
WITH DISTINCT friend, city, person
OPTIONAL MATCH (friend)<-[:POST_HAS_CREATOR]-(post:Post)
OPTIONAL MATCH (person)-[:HAS_INTEREST]->()<-[:HAS_TAG]-(post)
RETURN friend, city
@yixinglu yixinglu added the type/bug Type: something is unexpected label Nov 25, 2022
@yixinglu
Copy link
Contributor Author

image

I think we could NOT only allow the vertex output result as argument node reference variable. The right way to reference the variable in argument node is like the above image, the argument only concern the variable depended on.

@yixinglu
Copy link
Contributor Author

I update the query in following format, the execution plan become expected, the difference is only aliases in with clause.

MATCH (person:Person)-[:KNOWS]-(friend)
WHERE id(person) == "p-65504"
WITH person, collect(id(friend)) AS friends
MATCH (person:Person)-[:KNOWS*2]-(friend)-[:IS_LOCATED_IN]->(city:Place)
WHERE id(friend) != "p-65504" AND id(friend) NOT IN friends
WITH person, city, friend, datetime(friend.Person.birthday) as birthday
WHERE (birthday.month==5 AND birthday.day>=21) OR
        (birthday.month==(5%12)+1 AND birthday.day<22)
WITH DISTINCT friend AS f, city AS c, person AS p
OPTIONAL MATCH (f)<-[:POST_HAS_CREATOR]-(post:Post)
OPTIONAL MATCH (p)-[:HAS_INTEREST]->()<-[:HAS_TAG]-(post)
RETURN f, c

@Sophie-Xie Sophie-Xie added this to the v3.4.0 milestone Nov 27, 2022
@czpmango czpmango mentioned this issue Nov 29, 2022
11 tasks
@github-actions github-actions bot added the process/fixed Process of bug label Nov 29, 2022
@Hester-Gu Hester-Gu added the process/done Process of bug label Jan 13, 2023
@github-actions github-actions bot added affects/none PR/issue: this bug affects none version. severity/none Severity of bug and removed process/fixed Process of bug labels Jan 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects/none PR/issue: this bug affects none version. process/done Process of bug severity/none Severity of bug type/bug Type: something is unexpected
Projects
None yet
Development

No branches or pull requests

5 participants