Skip to content
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

CIP and Scenarios for precedence rules #502

Merged
merged 49 commits into from
Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
e734a61
CIP intro
hvub Aug 10, 2021
253c862
some intro refinement
hvub Aug 10, 2021
e384fc7
precedence table based on grammar
hvub Aug 10, 2021
2ac7248
precedence table based on grammar
hvub Aug 10, 2021
5b5ecf0
precedence level section
hvub Aug 10, 2021
3533ae9
some copyediting
hvub Aug 11, 2021
beaa8a1
some more copyediting
hvub Aug 11, 2021
b68cbba
some more copyediting
hvub Aug 11, 2021
ab277c0
precedence in chains
hvub Aug 11, 2021
5e1ccec
Examples for associative operators
hvub Aug 11, 2021
735fa78
some copyediting
hvub Aug 11, 2021
8e70ea8
more examples and some refactoring
hvub Aug 11, 2021
bd424ac
final test bits and some clean up
hvub Aug 11, 2021
6c0a9be
fix typo
hvub Aug 12, 2021
b8a6252
Fix typo
hvub Sep 1, 2021
986d7b0
Editorial fixes
hvub Oct 29, 2021
26e374c
Editorial fixes.
hvub Oct 29, 2021
1241126
Editorial fixes.
hvub Oct 29, 2021
bbfc5f8
Editorial fixes.
hvub Oct 29, 2021
26e836c
Editorial fixes.
hvub Oct 29, 2021
841d47a
Editorial fixes.
hvub Oct 29, 2021
9f7ed93
Fix grammar links
hvub Dec 3, 2021
e353efc
add pattern predicate as production
hvub Dec 3, 2021
d85a469
remove inlining of list comprehension
hvub Dec 3, 2021
30be654
Add quantifier production
hvub Dec 3, 2021
6f1cf6d
some reordering of productions
hvub Dec 3, 2021
6f77c99
properly refer to <Quantifiers> and <PatternPredicate>
hvub Dec 3, 2021
4e011f6
adjust to grammar refactoring
hvub Dec 3, 2021
c0aab32
add a note clarifying the level numbers
hvub Dec 3, 2021
0f5dd40
adjust precedence level table
hvub Dec 10, 2021
88f3994
rename StringOperatorExpression to StringPredicateExpression
hvub Dec 10, 2021
ee67951
rename NullOperatorExpression to NullPredicateExpression
hvub Dec 10, 2021
b10278f
Fix precedence of list ops in grammar CIP
hvub Dec 10, 2021
e6ea181
fix example with signed int
hvub Dec 13, 2021
9ef40db
fix example with signed int
hvub Dec 13, 2021
00b3d65
fix typo
hvub Dec 13, 2021
44414b3
fix typo
hvub Dec 13, 2021
a6c92d0
scenarios of precedence on boolean values
hvub Dec 14, 2021
25c77f0
scenarios of precedence on numeric values
hvub Dec 14, 2021
ff8edd8
update license header to 2022
hvub Jan 13, 2022
24d177f
Fix scenario name duplicate
hvub Mar 25, 2022
3a72741
Fix scenario name duplicate
hvub Mar 25, 2022
9f76d1e
Add precedence scenarios on list values
hvub May 2, 2022
31f3c88
Add precedence scenarios on null value
hvub May 2, 2022
a0e0f63
Fixing grammar and style errors
hvub May 6, 2022
d68ead0
Accept review suggestion
hvub May 25, 2022
7d5c454
Fixing double negation
hvub May 25, 2022
3e65414
Fixing failing scenarios
hvub May 25, 2022
e4b716f
add missing newline.
hvub Jun 3, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions cip/1.accepted/CIP2015-05-13-EXISTS.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,19 @@ In a predicate context this list gets coerced to a boolean (empty list -> [under
As a result, https://raw.githack.com/openCypher/openCypher/master/tools/grammar-production-links/grammarLink.html?p=RelationshipsPattern[<RelationshipsPattern>s] appear to behave differently depending on the context in which they appear.
Further, https://raw.githack.com/openCypher/openCypher/master/tools/grammar-production-links/grammarLink.html?p=PatternComprehension[<PatternComprehension>] offer a more powerful and syntactically better separated means to get lists of matches for a pattern within expressions.

The understanding of subqueries in Cypher has evolved and Cypher gained a proper https://raw.githack.com/openCypher/openCypher/master/tools/grammar-production-links/grammarLink.html?p=NullOperatorExpression[<NullOperatorExpression>] (`IS [ NOT ] NULL`), cf. https://github.com/opencypher/openCypher/blob/master/cip/1.accepted/CIP2018-10-29-EXISTS-and-IS-NOT-NULL.adoc[CIP2018-10-29 EXISTS and IS NOT NULL].
The understanding of subqueries in Cypher has evolved and Cypher gained a proper https://raw.githack.com/openCypher/openCypher/master/tools/grammar-production-links/grammarLink.html?p=NullPredicateExpression[<NullPredicateExpression>] (`IS [ NOT ] NULL`), cf. https://github.com/opencypher/openCypher/blob/master/cip/1.accepted/CIP2018-10-29-EXISTS-and-IS-NOT-NULL.adoc[CIP2018-10-29 EXISTS and IS NOT NULL].
Both developments and the issues around https://raw.githack.com/openCypher/openCypher/master/tools/grammar-production-links/grammarLink.html?p=RelationshipsPattern[<RelationshipsPattern>s] suggest the need for a refinement of the language constructs that allow testing of existence.

== Proposal

This CIP proposes:

* Restricting https://raw.githack.com/openCypher/openCypher/master/tools/grammar-production-links/grammarLink.html?p=RelationshipsPattern[<RelationshipsPattern>] to predicate contexts and boolean evaluation, when used in expression contexts
* Refer to a https://raw.githack.com/openCypher/openCypher/master/tools/grammar-production-links/grammarLink.html?p=RelationshipsPattern[<RelationshipsPattern>] appearing as an https://raw.githack.com/openCypher/openCypher/master/tools/grammar-production-links/grammarLink.html?p=Atom[<Atom>] as a https://raw.githack.com/openCypher/openCypher/master/tools/grammar-production-links/grammarLink.html?p=PatternPredicate[<PatternPredicate>] for better distinguishing it from a https://raw.githack.com/openCypher/openCypher/master/tools/grammar-production-links/grammarLink.html?p=RelationshipsPattern[<RelationshipsPattern>] appearing in a https://raw.githack.com/openCypher/openCypher/master/tools/grammar-production-links/grammarLink.html?p=PatternComprehension[<PatternComprehension>]
* Restricting https://raw.githack.com/openCypher/openCypher/master/tools/grammar-production-links/grammarLink.html?p=PatternPredicate[<PatternPredicate>] to predicate contexts and boolean evaluation, when used in expression contexts
* Adding two forms of existential subqueries denoted with `EXISTS { ... }`:
** Full existential subquery based on a https://raw.githack.com/openCypher/openCypher/master/tools/grammar-production-links/grammarLink.html?p=RegularQuery[<RegularQuery>]
** Simple existential subquery based on a single https://raw.githack.com/openCypher/openCypher/master/tools/grammar-production-links/grammarLink.html?p=Pattern[<Pattern>] and an optional https://raw.githack.com/openCypher/openCypher/master/tools/grammar-production-links/grammarLink.html?p=Where[<Where>] clause
* Removing `exists( n.prop )` in favor of the https://raw.githack.com/openCypher/openCypher/master/tools/grammar-production-links/grammarLink.html?p=NullOperatorExpression[<NullOperatorExpression>], which is a restatement of what has been accepted with https://github.com/opencypher/openCypher/blob/master/cip/1.accepted/CIP2018-10-29-EXISTS-and-IS-NOT-NULL.adoc[CIP2018-10-29 EXISTS and IS NOT NULL]
* Removing `exists( n.prop )` in favor of the https://raw.githack.com/openCypher/openCypher/master/tools/grammar-production-links/grammarLink.html?p=NullPredicateExpression[<NullPredicateExpression>], which is a restatement of what has been accepted with https://github.com/opencypher/openCypher/blob/master/cip/1.accepted/CIP2018-10-29-EXISTS-and-IS-NOT-NULL.adoc[CIP2018-10-29 EXISTS and IS NOT NULL]

=== Syntax

Expand All @@ -52,9 +53,12 @@ This CIP proposes:
----
<Atom> ::=
...
| <RelationshipsPattern>
| <PatternPredicate>
| <ExistentialSubquery>

<PatternPredicate> ::=
<RelationshipsPattern>

<ExistentialSubquery> ::=
<SimpleExistentialSubquery>
| <FullExistentialSubquery>
Expand All @@ -73,13 +77,13 @@ Note that the openCypher grammar does not list <SimpleExistentialSubquery>, <Sim

==== Syntax Rules

* A https://raw.githack.com/openCypher/openCypher/master/tools/grammar-production-links/grammarLink.html?p=RelationshipsPattern[<RelationshipsPattern>] shall only be contained in sites whose expected type is exactly boolean. To give the most frequent examples, a https://raw.githack.com/openCypher/openCypher/master/tools/grammar-production-links/grammarLink.html?p=RelationshipsPattern[<RelationshipsPattern>] can be simply contained in
* A https://raw.githack.com/openCypher/openCypher/master/tools/grammar-production-links/grammarLink.html?p=PatternPredicate[<PatternPredicate>] shall only be contained in sites whose expected type is exactly boolean. To give the most frequent examples, a https://raw.githack.com/openCypher/openCypher/master/tools/grammar-production-links/grammarLink.html?p=PatternPredicate[<PatternPredicate>] can be simply contained in
** <Where>, used in
*** https://raw.githack.com/openCypher/openCypher/master/tools/grammar-production-links/grammarLink.html?p=Match[<Match>]
*** https://raw.githack.com/openCypher/openCypher/master/tools/grammar-production-links/grammarLink.html?p=With[<With>]
*** https://raw.githack.com/openCypher/openCypher/master/tools/grammar-production-links/grammarLink.html?p=YieldItems[<YieldItems>]
*** https://raw.githack.com/openCypher/openCypher/master/tools/grammar-production-links/grammarLink.html?p=FilterExpression[<FilterExpression>], used in
**** `ALL`, `ANY`, `NONE`, `SINGLE`
**** https://raw.githack.com/openCypher/openCypher/master/tools/grammar-production-links/grammarLink.html?p=Quantifiers[<Quantifiers>]
**** https://raw.githack.com/openCypher/openCypher/master/tools/grammar-production-links/grammarLink.html?p=ListComprehension[<ListComprehension>]
*** https://raw.githack.com/openCypher/openCypher/master/tools/grammar-production-links/grammarLink.html?p=PatternComprehension[<PatternComprehension>]
** https://raw.githack.com/openCypher/openCypher/master/tools/grammar-production-links/grammarLink.html?p=CaseAlternative[<CaseAlternative>]
Expand All @@ -89,7 +93,7 @@ Note that the openCypher grammar does not list <SimpleExistentialSubquery>, <Sim

=== Semantics

https://raw.githack.com/openCypher/openCypher/master/tools/grammar-production-links/grammarLink.html?p=RelationshipsPattern[<RelationshipsPattern>], <SimpleExistentialSubquery>, and <FullExistentialSubquery> accomplish the same task: checking whether the result of a subquery is not empty.
https://raw.githack.com/openCypher/openCypher/master/tools/grammar-production-links/grammarLink.html?p=PatternPredicate[<PatternPredicate>], <SimpleExistentialSubquery>, and <FullExistentialSubquery> accomplish the same task: checking whether the result of a subquery is not empty.

All three forms,

Expand All @@ -98,20 +102,20 @@ All three forms,
* Are side effect-free, i.e. <FullExistentialSubquery> shall not contain any <UpdatingClause> or other sources of side effects
* Can contain variables and parameters from the outer queries

https://raw.githack.com/openCypher/openCypher/master/tools/grammar-production-links/grammarLink.html?p=RelationshipsPattern[<RelationshipsPattern>] shall not introduce new variables.
https://raw.githack.com/openCypher/openCypher/master/tools/grammar-production-links/grammarLink.html?p=PatternPredicate[<PatternPredicate>] shall not introduce new variables.

Both forms of https://raw.githack.com/openCypher/openCypher/master/tools/grammar-production-links/grammarLink.html?p=ExistentialSubquery[<ExistentialSubquery>] (<SimpleExistentialSubquery> and <FullExistentialSubquery>) are allowed to introduce new variables.
These variables necessarily shall have a name different from the names of all variables available from the outer queries.
Any variables introduced in an <ExistentialSubquery> are not available outside the subquery context.

https://raw.githack.com/openCypher/openCypher/master/tools/grammar-production-links/grammarLink.html?p=RelationshipsPattern[<RelationshipsPattern>] and <SimpleExistentialSubquery> are syntactically simpler and semantically less powerful forms of <FullExistentialSubquery>.
The semantics of https://raw.githack.com/openCypher/openCypher/master/tools/grammar-production-links/grammarLink.html?p=RelationshipsPattern[<RelationshipsPattern>] and <SimpleExistentialSubquery> can be defined as syntax transformations to <FullExistentialSubquery>.
https://raw.githack.com/openCypher/openCypher/master/tools/grammar-production-links/grammarLink.html?p=PatternPredicate[<PatternPredicate>] and <SimpleExistentialSubquery> are syntactically simpler and semantically less powerful forms of <FullExistentialSubquery>.
The semantics of https://raw.githack.com/openCypher/openCypher/master/tools/grammar-production-links/grammarLink.html?p=PatternPredicate[<PatternPredicate>] and <SimpleExistentialSubquery> can be defined as syntax transformations to <FullExistentialSubquery>.

==== <RelationshipsPattern>

A https://raw.githack.com/openCypher/openCypher/master/tools/grammar-production-links/grammarLink.html?p=RelationshipsPattern[<RelationshipsPattern>] _RP_ is effectively replaced by the expression
A https://raw.githack.com/openCypher/openCypher/master/tools/grammar-production-links/grammarLink.html?p=PatternPredicate[<PatternPredicate>] _PP_ is effectively replaced by the expression

`EXISTS { MATCH _RP_ RETURN 1 }`
`EXISTS { MATCH _PP_ RETURN 1 }`

==== <SimpleExistentialSubquery>

Expand Down
Loading