You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Two relationship variables in one pattern can bind the same edge #59
openCypher matches each relationship at most once within one pattern (relationship isomorphism). Here, two relationship variables in the same pattern can bind the same edge.
Reproduction
importpyarrowaspafromlance_csrimportCypherEngine, GraphConfigconfig= (
GraphConfig.builder()
.node_table("Person", "id")
.rel_table("KNOWS", "Person", "Person", "src", "dst")
.build()
)
people=pa.table({"id": [1, 2, 3, 4], "name": ["A", "B", "C", "D"]})
engine=CypherEngine(config, {"Person": people, "KNOWS": pa.table({"src": [1, 3], "dst": [2, 2]})})
engine.execute(
"MATCH (a:Person)-[r1:KNOWS]->(b:Person)<-[r2:KNOWS]-(c:Person) ""RETURN a.name AS a, c.name AS c ORDER BY a, c"
).to_pylist()
This returns 4 rows, including {'a': 'A', 'c': 'A'} and {'a': 'C', 'c': 'C'}, where r1 and r2 are the same edge. openCypher returns 2 rows (A, C and C, A). The result is the same with and without use_csr=True. Named paths are not affected: the path operator from #55 already enforces it.
Suggested fix
For each pair of relationship variables of compatible types in one pattern, add a filter that their identities differ, as the path operator does.
Activity
fix(planner): match a reused relationship variable as the same edge (#83