{"action":"created","comment":{"url":"https://api.github.com/repos/opencypher/openCypher/pulls/comments/71280971","id":71280971,"diff_hunk":"@@ -0,0 +1,167 @@\n+= CIP2015-05-13 - EXISTENTIAL SUBQUERIES\n+:numbered:\n+:toc:\n+:toc-placement: macro\n+:source-highlighter: codemirror\n+\n+*Authors:* Andrés Taylor <andres@neotechnology.com>\n+\n+\n+[abstract]\n+.Abstract\n+--\n+This CIP introduces `EXISTS`, a function and a keyword for checking the existence of properties, simple patterns and full subqueries.\n+--\n+\n+toc::[]\n+\n+== Background\n+\n+In a way, Cypher already has existential subqueries - pattern predicates allow checking for the existence of subgraphs.\n+This form is helpful, but not exhaustive in the types of subqueries that users want to be able to express.\n+\n+== Proposal\n+\n+To make this feature more powerful, add a new function named `exists`, and a keyword named the same, which allows for two different predicates:\n+\n+ * Property existence checking\n+ * Subquery existence checking\n+\n+=== Syntax\n+\n+----\n+expression = <current definition of expression>\n+           | property exists\n+           | subquery exists\n+           | simple subquery exists\n+            ;\n+\n+property exists = \"exists\", \"(\", expression \")\"\n+                ;\n+\n+subquery exists = \"EXISTS\", \"{\", read only clause, { read only clause }, \"}\" ;\n+\n+simple subquery exists = \"EXISTS\", \"{\", simple match, \"}\" ;\n+\n+simple match = pattern, { \",\", pattern }, [ \"WHERE\", predicate ] ;\n+\n+----\n+Note: the read-only clause above includes WITH but not RETURN.\n+\n+=== Semantics\n+\n+All forms of `EXIST(...)` accomplish the same task - check if a particular pattern exists in the database.\n+They are expressions, and as such must be side-effect free; that is, the subqueries in `EXISTS` must not be updating queries.\n+All forms of `EXISTS` are scalar expressions - they return a single boolean value, and this value is never `null`.\n+\n+==== Property exists\n+\n+In the property checking form, any expression is accepted as the input.\n+If the input expression would have produced a `null` value, `exists(...)`` evaluates to false, and for all other values, it will return `true`.\n+This form of `exists(...)` is equivalent to checking for `null` using `IS NOT NULL`; i.e. `exists(expr)` is equivalent to `expr IS NOT NULL`.\n+\n+This form is there to make property existence checking idiomatic in Cypher - we do not want the user thinking of missing properties as checking for `null` values.\n+\n+==== Subquery exists\n+When checking for the existence of subqueries, variables and parameters from the outer query are available in the subquery.\n+Variables introduced in the subquery are not available on the outside.\n+\n+For each matching subgraph evaluated with `EXISTS{...}`, the result value must be true if the subquery finds at least one matching row.\n+If no matches are found, false should be returned.\n+\n+The subquery used in `EXISTS{...}` has to follow the following rules:\n+\n+ * It has to be a read-only query. Updating the graph as part of a predicate is not allowed.\n+ * It cannot end in a `RETURN` clause, nor may it contain `UNION`\n+ * If `WITH` ends the subquery, it should be able to change the cardinality of the subquery.\n+ In other words, the `WITH` clause should include `WHERE` or `SKIP`, since these sub-clauses can turn a query that returns rows into one that does not.\n+\n+==== Simple subquery exists\n+When the subquery can be described with a single `MATCH-WHERE` clause, the `MATCH` keyword can be omitted, as in example 2A and B.\n+The difference between this form and a simple pattern predicate, which is already available, is that this form allows for introducing new variables inside the `EXISTS(...)` scope.\n+\n+=== Examples\n+_Example 1A:_\n+\n+Return all nodes that have a property named `slogan`.\n+[source, cypher]\n+----\n+MATCH (actor)\n+WHERE EXISTS(actor.slogan)\n+RETURN actor\n+----\n+\n+_Example 2A:_\n+\n+Find all actors who have acted together with another actor with the same name.\n+\n+[source, cypher]\n+----\n+MATCH (actor:Actor)\n+WHERE EXISTS {\n+\t(other:Actor)-[:ACTED_IN]->(movie)<-[:ACTED_IN]-(actor)\n+\tWHERE other.name = actor.name\n+}\n+RETURN actor\n+----\n+\n+_Example 2B:_\n+\n+Find all actors who have acted together with another actor with the same name on at least two movies.\n+\n+[source, cypher]\n+----\n+MATCH (actor:Actor)\n+WHERE EXISTS {\n+\tMATCH (other:Actor)-[:ACTED_IN]->(movie)<-[:ACTED_IN]-(actor)\n+\tWHERE other.name = actor.name\n+  WITH other, count(*) as c\n+  WHERE c > 1\n+}\n+RETURN actor\n+----\n+\n+=== Interaction with existing features\n+This replaces the pre-existing `HAS(...)` function.\n+\n+== What others do\n+\n+This is very similar to what SQL does with its EXISTS functionality.\n+\n+This is also very similar in syntax to what SPARQL does with its EXISTS functionality; the rules regarding variables are identical, and the inner query also takes a subquery as input.","path":"cip/CIP2015-05-13-EXISTS.adoc","position":131,"original_position":131,"commit_id":"0930149beeddaa2b516b369d39d45a9588c62276","original_commit_id":"0930149beeddaa2b516b369d39d45a9588c62276","user":{"login":"Mats-SX","id":2419675,"avatar_url":"https://avatars.githubusercontent.com/u/2419675?v=3","gravatar_id":"","url":"https://api.github.com/users/Mats-SX","html_url":"https://github.com/Mats-SX","followers_url":"https://api.github.com/users/Mats-SX/followers","following_url":"https://api.github.com/users/Mats-SX/following{/other_user}","gists_url":"https://api.github.com/users/Mats-SX/gists{/gist_id}","starred_url":"https://api.github.com/users/Mats-SX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mats-SX/subscriptions","organizations_url":"https://api.github.com/users/Mats-SX/orgs","repos_url":"https://api.github.com/users/Mats-SX/repos","events_url":"https://api.github.com/users/Mats-SX/events{/privacy}","received_events_url":"https://api.github.com/users/Mats-SX/received_events","type":"User","site_admin":false},"body":"Backticks for `EXISTS`","created_at":"2016-07-19T06:55:16Z","updated_at":"2016-07-19T06:55:16Z","html_url":"https://github.com/opencypher/openCypher/pull/10#discussion_r71280971","pull_request_url":"https://api.github.com/repos/opencypher/openCypher/pulls/10","_links":{"self":{"href":"https://api.github.com/repos/opencypher/openCypher/pulls/comments/71280971"},"html":{"href":"https://github.com/opencypher/openCypher/pull/10#discussion_r71280971"},"pull_request":{"href":"https://api.github.com/repos/opencypher/openCypher/pulls/10"}}},"pull_request":{"url":"https://api.github.com/repos/opencypher/openCypher/pulls/10","id":48832258,"html_url":"https://github.com/opencypher/openCypher/pull/10","diff_url":"https://github.com/opencypher/openCypher/pull/10.diff","patch_url":"https://github.com/opencypher/openCypher/pull/10.patch","issue_url":"https://api.github.com/repos/opencypher/openCypher/issues/10","number":10,"state":"open","locked":false,"title":"Adds the EXISTS CIP","user":{"login":"systay","id":402248,"avatar_url":"https://avatars.githubusercontent.com/u/402248?v=3","gravatar_id":"","url":"https://api.github.com/users/systay","html_url":"https://github.com/systay","followers_url":"https://api.github.com/users/systay/followers","following_url":"https://api.github.com/users/systay/following{/other_user}","gists_url":"https://api.github.com/users/systay/gists{/gist_id}","starred_url":"https://api.github.com/users/systay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/systay/subscriptions","organizations_url":"https://api.github.com/users/systay/orgs","repos_url":"https://api.github.com/users/systay/repos","events_url":"https://api.github.com/users/systay/events{/privacy}","received_events_url":"https://api.github.com/users/systay/received_events","type":"User","site_admin":false},"body":"Replaces #8","created_at":"2015-10-27T06:11:04Z","updated_at":"2016-07-19T06:55:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8c20b63005054ef13547c89eb0f75265df12b3c9","assignee":{"login":"thobe","id":104385,"avatar_url":"https://avatars.githubusercontent.com/u/104385?v=3","gravatar_id":"","url":"https://api.github.com/users/thobe","html_url":"https://github.com/thobe","followers_url":"https://api.github.com/users/thobe/followers","following_url":"https://api.github.com/users/thobe/following{/other_user}","gists_url":"https://api.github.com/users/thobe/gists{/gist_id}","starred_url":"https://api.github.com/users/thobe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thobe/subscriptions","organizations_url":"https://api.github.com/users/thobe/orgs","repos_url":"https://api.github.com/users/thobe/repos","events_url":"https://api.github.com/users/thobe/events{/privacy}","received_events_url":"https://api.github.com/users/thobe/received_events","type":"User","site_admin":false},"assignees":[{"login":"thobe","id":104385,"avatar_url":"https://avatars.githubusercontent.com/u/104385?v=3","gravatar_id":"","url":"https://api.github.com/users/thobe","html_url":"https://github.com/thobe","followers_url":"https://api.github.com/users/thobe/followers","following_url":"https://api.github.com/users/thobe/following{/other_user}","gists_url":"https://api.github.com/users/thobe/gists{/gist_id}","starred_url":"https://api.github.com/users/thobe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thobe/subscriptions","organizations_url":"https://api.github.com/users/thobe/orgs","repos_url":"https://api.github.com/users/thobe/repos","events_url":"https://api.github.com/users/thobe/events{/privacy}","received_events_url":"https://api.github.com/users/thobe/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/opencypher/openCypher/pulls/10/commits","review_comments_url":"https://api.github.com/repos/opencypher/openCypher/pulls/10/comments","review_comment_url":"https://api.github.com/repos/opencypher/openCypher/pulls/comments{/number}","comments_url":"https://api.github.com/repos/opencypher/openCypher/issues/10/comments","statuses_url":"https://api.github.com/repos/opencypher/openCypher/statuses/0930149beeddaa2b516b369d39d45a9588c62276","head":{"label":"systay:exists","ref":"exists","sha":"0930149beeddaa2b516b369d39d45a9588c62276","user":{"login":"systay","id":402248,"avatar_url":"https://avatars.githubusercontent.com/u/402248?v=3","gravatar_id":"","url":"https://api.github.com/users/systay","html_url":"https://github.com/systay","followers_url":"https://api.github.com/users/systay/followers","following_url":"https://api.github.com/users/systay/following{/other_user}","gists_url":"https://api.github.com/users/systay/gists{/gist_id}","starred_url":"https://api.github.com/users/systay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/systay/subscriptions","organizations_url":"https://api.github.com/users/systay/orgs","repos_url":"https://api.github.com/users/systay/repos","events_url":"https://api.github.com/users/systay/events{/privacy}","received_events_url":"https://api.github.com/users/systay/received_events","type":"User","site_admin":false},"repo":{"id":44969490,"name":"openCypher","full_name":"systay/openCypher","owner":{"login":"systay","id":402248,"avatar_url":"https://avatars.githubusercontent.com/u/402248?v=3","gravatar_id":"","url":"https://api.github.com/users/systay","html_url":"https://github.com/systay","followers_url":"https://api.github.com/users/systay/followers","following_url":"https://api.github.com/users/systay/following{/other_user}","gists_url":"https://api.github.com/users/systay/gists{/gist_id}","starred_url":"https://api.github.com/users/systay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/systay/subscriptions","organizations_url":"https://api.github.com/users/systay/orgs","repos_url":"https://api.github.com/users/systay/repos","events_url":"https://api.github.com/users/systay/events{/privacy}","received_events_url":"https://api.github.com/users/systay/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/systay/openCypher","description":"Specification of the Cypher query language","fork":true,"url":"https://api.github.com/repos/systay/openCypher","forks_url":"https://api.github.com/repos/systay/openCypher/forks","keys_url":"https://api.github.com/repos/systay/openCypher/keys{/key_id}","collaborators_url":"https://api.github.com/repos/systay/openCypher/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/systay/openCypher/teams","hooks_url":"https://api.github.com/repos/systay/openCypher/hooks","issue_events_url":"https://api.github.com/repos/systay/openCypher/issues/events{/number}","events_url":"https://api.github.com/repos/systay/openCypher/events","assignees_url":"https://api.github.com/repos/systay/openCypher/assignees{/user}","branches_url":"https://api.github.com/repos/systay/openCypher/branches{/branch}","tags_url":"https://api.github.com/repos/systay/openCypher/tags","blobs_url":"https://api.github.com/repos/systay/openCypher/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/systay/openCypher/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/systay/openCypher/git/refs{/sha}","trees_url":"https://api.github.com/repos/systay/openCypher/git/trees{/sha}","statuses_url":"https://api.github.com/repos/systay/openCypher/statuses/{sha}","languages_url":"https://api.github.com/repos/systay/openCypher/languages","stargazers_url":"https://api.github.com/repos/systay/openCypher/stargazers","contributors_url":"https://api.github.com/repos/systay/openCypher/contributors","subscribers_url":"https://api.github.com/repos/systay/openCypher/subscribers","subscription_url":"https://api.github.com/repos/systay/openCypher/subscription","commits_url":"https://api.github.com/repos/systay/openCypher/commits{/sha}","git_commits_url":"https://api.github.com/repos/systay/openCypher/git/commits{/sha}","comments_url":"https://api.github.com/repos/systay/openCypher/comments{/number}","issue_comment_url":"https://api.github.com/repos/systay/openCypher/issues/comments{/number}","contents_url":"https://api.github.com/repos/systay/openCypher/contents/{+path}","compare_url":"https://api.github.com/repos/systay/openCypher/compare/{base}...{head}","merges_url":"https://api.github.com/repos/systay/openCypher/merges","archive_url":"https://api.github.com/repos/systay/openCypher/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/systay/openCypher/downloads","issues_url":"https://api.github.com/repos/systay/openCypher/issues{/number}","pulls_url":"https://api.github.com/repos/systay/openCypher/pulls{/number}","milestones_url":"https://api.github.com/repos/systay/openCypher/milestones{/number}","notifications_url":"https://api.github.com/repos/systay/openCypher/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/systay/openCypher/labels{/name}","releases_url":"https://api.github.com/repos/systay/openCypher/releases{/id}","deployments_url":"https://api.github.com/repos/systay/openCypher/deployments","created_at":"2015-10-26T13:17:41Z","updated_at":"2015-10-25T15:11:13Z","pushed_at":"2016-06-23T08:18:10Z","git_url":"git://github.com/systay/openCypher.git","ssh_url":"git@github.com:systay/openCypher.git","clone_url":"https://github.com/systay/openCypher.git","svn_url":"https://github.com/systay/openCypher","homepage":null,"size":2215,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"opencypher:master","ref":"master","sha":"630062273b04d0bcdd4cdaff507296fe5ddc458c","user":{"login":"opencypher","id":14857376,"avatar_url":"https://avatars.githubusercontent.com/u/14857376?v=3","gravatar_id":"","url":"https://api.github.com/users/opencypher","html_url":"https://github.com/opencypher","followers_url":"https://api.github.com/users/opencypher/followers","following_url":"https://api.github.com/users/opencypher/following{/other_user}","gists_url":"https://api.github.com/users/opencypher/gists{/gist_id}","starred_url":"https://api.github.com/users/opencypher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opencypher/subscriptions","organizations_url":"https://api.github.com/users/opencypher/orgs","repos_url":"https://api.github.com/users/opencypher/repos","events_url":"https://api.github.com/users/opencypher/events{/privacy}","received_events_url":"https://api.github.com/users/opencypher/received_events","type":"Organization","site_admin":false},"repo":{"id":30405191,"name":"openCypher","full_name":"opencypher/openCypher","owner":{"login":"opencypher","id":14857376,"avatar_url":"https://avatars.githubusercontent.com/u/14857376?v=3","gravatar_id":"","url":"https://api.github.com/users/opencypher","html_url":"https://github.com/opencypher","followers_url":"https://api.github.com/users/opencypher/followers","following_url":"https://api.github.com/users/opencypher/following{/other_user}","gists_url":"https://api.github.com/users/opencypher/gists{/gist_id}","starred_url":"https://api.github.com/users/opencypher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opencypher/subscriptions","organizations_url":"https://api.github.com/users/opencypher/orgs","repos_url":"https://api.github.com/users/opencypher/repos","events_url":"https://api.github.com/users/opencypher/events{/privacy}","received_events_url":"https://api.github.com/users/opencypher/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/opencypher/openCypher","description":"Specification of the Cypher query language","fork":false,"url":"https://api.github.com/repos/opencypher/openCypher","forks_url":"https://api.github.com/repos/opencypher/openCypher/forks","keys_url":"https://api.github.com/repos/opencypher/openCypher/keys{/key_id}","collaborators_url":"https://api.github.com/repos/opencypher/openCypher/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/opencypher/openCypher/teams","hooks_url":"https://api.github.com/repos/opencypher/openCypher/hooks","issue_events_url":"https://api.github.com/repos/opencypher/openCypher/issues/events{/number}","events_url":"https://api.github.com/repos/opencypher/openCypher/events","assignees_url":"https://api.github.com/repos/opencypher/openCypher/assignees{/user}","branches_url":"https://api.github.com/repos/opencypher/openCypher/branches{/branch}","tags_url":"https://api.github.com/repos/opencypher/openCypher/tags","blobs_url":"https://api.github.com/repos/opencypher/openCypher/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/opencypher/openCypher/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/opencypher/openCypher/git/refs{/sha}","trees_url":"https://api.github.com/repos/opencypher/openCypher/git/trees{/sha}","statuses_url":"https://api.github.com/repos/opencypher/openCypher/statuses/{sha}","languages_url":"https://api.github.com/repos/opencypher/openCypher/languages","stargazers_url":"https://api.github.com/repos/opencypher/openCypher/stargazers","contributors_url":"https://api.github.com/repos/opencypher/openCypher/contributors","subscribers_url":"https://api.github.com/repos/opencypher/openCypher/subscribers","subscription_url":"https://api.github.com/repos/opencypher/openCypher/subscription","commits_url":"https://api.github.com/repos/opencypher/openCypher/commits{/sha}","git_commits_url":"https://api.github.com/repos/opencypher/openCypher/git/commits{/sha}","comments_url":"https://api.github.com/repos/opencypher/openCypher/comments{/number}","issue_comment_url":"https://api.github.com/repos/opencypher/openCypher/issues/comments{/number}","contents_url":"https://api.github.com/repos/opencypher/openCypher/contents/{+path}","compare_url":"https://api.github.com/repos/opencypher/openCypher/compare/{base}...{head}","merges_url":"https://api.github.com/repos/opencypher/openCypher/merges","archive_url":"https://api.github.com/repos/opencypher/openCypher/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/opencypher/openCypher/downloads","issues_url":"https://api.github.com/repos/opencypher/openCypher/issues{/number}","pulls_url":"https://api.github.com/repos/opencypher/openCypher/pulls{/number}","milestones_url":"https://api.github.com/repos/opencypher/openCypher/milestones{/number}","notifications_url":"https://api.github.com/repos/opencypher/openCypher/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/opencypher/openCypher/labels{/name}","releases_url":"https://api.github.com/repos/opencypher/openCypher/releases{/id}","deployments_url":"https://api.github.com/repos/opencypher/openCypher/deployments","created_at":"2015-02-06T09:35:42Z","updated_at":"2016-07-17T21:37:05Z","pushed_at":"2016-07-18T22:10:13Z","git_url":"git://github.com/opencypher/openCypher.git","ssh_url":"git@github.com:opencypher/openCypher.git","clone_url":"https://github.com/opencypher/openCypher.git","svn_url":"https://github.com/opencypher/openCypher","homepage":"http://www.opencypher.org","size":2401,"stargazers_count":88,"watchers_count":88,"language":"Cucumber","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":19,"mirror_url":null,"open_issues_count":17,"forks":19,"open_issues":17,"watchers":88,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/opencypher/openCypher/pulls/10"},"html":{"href":"https://github.com/opencypher/openCypher/pull/10"},"issue":{"href":"https://api.github.com/repos/opencypher/openCypher/issues/10"},"comments":{"href":"https://api.github.com/repos/opencypher/openCypher/issues/10/comments"},"review_comments":{"href":"https://api.github.com/repos/opencypher/openCypher/pulls/10/comments"},"review_comment":{"href":"https://api.github.com/repos/opencypher/openCypher/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/opencypher/openCypher/pulls/10/commits"},"statuses":{"href":"https://api.github.com/repos/opencypher/openCypher/statuses/0930149beeddaa2b516b369d39d45a9588c62276"}}}}
{"actor":{"display_login":"Mats-SX"}}