joefagan commented on issue #140:
URL: https://github.com/apache/incubator-age/issues/140#issuecomment-963302082


   
   @deem0n has uncovered something for sure.
   
   The AGE behaviour is quite different from that of Neo4j sandbox (or 
AgensGraph) where the NOT EXISTS seems to find edges that could exist but 
don't. EG even for an orphaned node {name: "a"}, the only node in the graph,
   ```
   MATCH (a),(b) WHERE NOT EXISTS((a)-[]->(b)) return a.name, b.name;
   ```
   returns
   "a", "a"
   since there is no loop edge from a to a.
   
   See more examples below and how to create them from scratch
    
   ```
   -- create new graph
   SELECT * FROM create_graph('test');
   
   -- create a vertex with no edges
   SELECT * FROM cypher('test', $$
   CREATE (a:Engine {name: "orphan"})
   $$) as (a agtype);
   
   SELECT * FROM cypher('test', 
   $$MATCH (f:Engine),(t:Engine)
   WHERE NOT EXISTS((f)-[]->(t))
   RETURN f,t$$) as (f agtype, t agtype);
   ```
   returns 0 rows.
   Equivalent commands in neo4j sandbox
   ```
   create (a:Engine{name: "Orphan"});
   MATCH (f:Engine),(t:Engine) WHERE NOT EXISTS((f)-[]->(t)) RETURN f.name, 
t.name;
   ```
   
   returns 1 row
   f.name, t.name
   "Orphan", "Orphan"
   
   With more nodes the difference in behaviour is noticeable
   
   NOT EXISTS behaviour in AGE is not quite what is expected.
   
   ```
   -- create 2 nodes and an edge
   -- ({name: "F"})-[:r]->(name: "T")
   SELECT * FROM cypher('test', $$
   CREATE (a:Engine {name: "F"}) -[:r]- > (:engine {name: "T"})
   $$) as (bla agtype);
   
   SELECT * FROM cypher('test', 
   $$MATCH (f:Engine),(t:Engine)
   WHERE NOT EXISTS((f)-[]->(t))
   RETURN f.name, t.name $$) as (f agtype, t agtype);
   ```
   again returns no rows, whereas the equivalent commands in neo4j returns 5
   f.name       t.name
   "Orphan"     "Orphan"
   "Orphan"     "F"
   "F"  "Orphan"
   "F"  "F"
   
   
   
   
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to