-
Notifications
You must be signed in to change notification settings - Fork 230
Question on MATCH query (cartesian product) #249
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
Comments
Hi @andrija78 But one think to notice, this graph contains 9 edges, and so each edge will appear 4 times and so I would expect 27 results, when reversing the order: Thank you for reporting! |
You are right; 27 rows are expected. I ran a different test before, I mixed up the numbers. When can we expect support for multiple MATCH queries - so I can avoid Cartesian product like this:
|
I'm not sure exactly when multiple MATCH clauses will be supported, as we're finalising our roadmap these days, I can say that this is defiantly on the roadmap, I think it wouldn't take too long to implement,
Is the as executing:
Unless I'm missing something, |
@andrija78 just pushed a fix, could you please verify. |
This was fast! Thanks!
|
Hi,
I'm testing some MATCH queries, and found weird behavior with Cartesian product.
Am I doing something wrong, my understanding is wrong, or is this a bug?
BTW - I'm testing this since multiple match statements are not supported yet - something like:
I have a simple graph: 4 persons, 3 cities. Persons A, B and C visited 2 cities. Person D visited all 3 cities.
These 2 queries have a result that does not look correct:
Here I'm expecting to get all 12 visits, joined with 3 cities - 36 rows in total.
But only person D gets cartesian right with all 3 cities; persons A, B and C only get matched with city 1.
MATCH (a:person)-[:visited]->(b:city), (c:city) return a,b,c
[last A, name A, country 1, city 1, country 1, city 1]
[last A, name A, country 2, city 2, country 1, city 1]
[last B, name B, country 1, city 1, country 1, city 1]
[last B, name B, country 3, city 3, country 1, city 1]
[last C, name C, country 2, city 2, country 1, city 1]
[last C, name C, country 3, city 3, country 1, city 1]
[last D, name D, country 1, city 1, country 1, city 1]
[last D, name D, country 2, city 2, country 1, city 1]
[last D, name D, country 3, city 3, country 1, city 1]
[last D, name D, country 1, city 1, country 2, city 2]
[last D, name D, country 2, city 2, country 2, city 2]
[last D, name D, country 3, city 3, country 2, city 2]
[last D, name D, country 1, city 1, country 3, city 3]
[last D, name D, country 2, city 2, country 3, city 3]
[last D, name D, country 3, city 3, country 3, city 3]
Similarly, when applying additional filter:
MATCH (a:person)-[:visited]->(b:city), (c:city) where b.name=c.name return a,b,c
[last A, name A, country 1, city 1, country 1, city 1]
[last B, name B, country 1, city 1, country 1, city 1]
[last D, name D, country 1, city 1, country 1, city 1]
[last B, name B, country 3, city 3, country 3, city 3]
[last C, name C, country 3, city 3, country 3, city 3]
[last D, name D, country 3, city 3, country 3, city 3]
The text was updated successfully, but these errors were encountered: