bitnine-oss / agensgraph

AgensGraph, a transactional graph database based on PostgreSQL
http://www.agensgraph.org
Other
1.33k stars 148 forks source link

VLE Match is returning duplicate paths #541

Closed joefagan closed 2 years ago

joefagan commented 3 years ago

image

-- CREATE the graph

drop graph if exists john cascade;
create graph if not exists john;
set graph_path = john;
CREATE (b:begin)-[:edge {name: '1'}]->(u1:middle)-[:edge {name: '2'}]->(u2:middle)-[:edge {name: '3'}]
->(u3:middle)-[:edge {name: '4'}]->(e:"end"),

(u1)-[:self_loop]->(u1), 
(e)-[:self_loop]->(e), 
(b)-[:second]->(u1), 
(u2)-[:second]->(u3), 
(u3)-[:second]->(e), 
(u2)-[:bypass]->(e), 
(e)-[:back_up]->(u3), 
(u3)-[:back_up]->(u2), 
(u2)-[:bypass_up]->(b) 
return b, e;

match p = (:begin) - [*.. ] - (:"end") return count (p); count 16926 (1 row)

match p = (:begin) - [*.. ] - (:"end") return count (distinct p); count 7092 (1 row)

Should these match queries return the same count?

emotionbug commented 3 years ago

I can't understand what you want...

joefagan commented 2 years ago

I want to know whether the two match queries return the same count?

mwcho-agtech commented 2 years ago

You need to understand distinct first. DISTINCT is eliminate all the duplicate records and fetching only unique records. Therefore, the results of the two queries may be different depending on the existence of duplicate data.