CIP2017-04-20: Query Combinators for set operations#227
CIP2017-04-20: Query Combinators for set operations#227boggle wants to merge 9 commits intoopencypher:masterfrom
Conversation
| * `CROSS` | ||
| * `THEN` | ||
|
|
||
| Multi-arm query combinators can only appear within a query using the syntax `<query> [<combinator> <query>]+`. |
There was a problem hiding this comment.
I would prefer if the syntax was expressed in EBNF, similar to how other CIPs do that.
query = singleQuery | combinedQuery ;
combinedQuery = singleQuery, queryCombinator, singleQuery ;
queryCombinator = union | intersect | except | otherwise | cross | then ;
union = "UNION", ["MAX" | "ALL"] ;
...
|
|
||
| This does not consider aliasing of subqueries; henceforth set operations over the same argument queries need to repeat the argument subqueries. | ||
|
|
||
| This could be addressed in a future CIP. |
There was a problem hiding this comment.
I'd suggest merging this with the previous paragraph.
| This is due to its syntactic status as a query combinator. | ||
|
|
||
| In contrast to the other query combinators, the standard rules regarding returned record fields do not apply to `THEN`. | ||
| Instead, the set of returned record fields of both arms of `THEN` must be non-overlapping. |
There was a problem hiding this comment.
Why is this required? Isn't this query perfectly reasonable:
RETURN 1 AS one, 2 AS two
THEN
RETURN one + 5 AS one, one + two AS three
And the full statement would return the fields one and three?
|
|
||
| `OTHERWISE` is not provided by SQL and could be omitted. | ||
|
|
||
| SQL allows `MINUS` as an alias for `EXCEPT`. |
There was a problem hiding this comment.
Acknowledging a potential Pythonic bias, I have a strong preference for MINUS over EXCEPT here. EXCEPT draws to mind exceptions and feels too general as a term. Conversely, MINUS leads to mathematical difference, which is entirely appropriate.
c917667 to
d361d44
Compare
d361d44 to
bdf4be1
Compare
This also pushes `union` and `singleQuery` properties down from the RegularQuery
to the new CombinedQuery interface.
This way, SingleQuery is cleaned from those unused properties.
When 3 or more SingleQueries built up a union query, it used to be modeled
as a tree where each union node added one more SingleQuery like
```
S1
UNION
S2
UNION
S3
```
was modeled as
```
RegularQuery
+-singleQuery: RegularQuery
| +-singleQuery: SingleQuery S1
| +-union:
| +-[list entry]: Union
| +-singleQuery: SingleQuery S2
+-union:
+-list entry: Union
+-singleQuery: SingleQuery S3
```
From now, the representation is as follows, where RegularQuery has 2 subclasses:
- SingleQuery used for sole queries not having any UNION clauses
- CombinedQuery used for queries that have at least one query combinator
(UNION in current openCypher, but other set combinators like INTERSECT
are about to come, see opencypher/openCypher#227)
```
CombinedQuery
+-singleQuery: SingleQuery S1
+-union:
+-[list entry]: Union
+-singleQuery: SingleQuery S2
+-[list entry]: Union
+-singleQuery: SingleQuery S3
```
This also pushes `union` and `singleQuery` properties down from the RegularQuery
to the new CombinedQuery interface.
This way, SingleQuery is cleaned from those unused properties.
When 3 or more SingleQueries built up a union query, it used to be modeled
as a tree where each union node added one more SingleQuery like
```
S1
UNION
S2
UNION
S3
```
was modeled as
```
RegularQuery
+-singleQuery: RegularQuery
| +-singleQuery: SingleQuery S1
| +-union:
| +-[list entry]: Union
| +-singleQuery: SingleQuery S2
+-union:
+-list entry: Union
+-singleQuery: SingleQuery S3
```
From now, the representation is as follows, where RegularQuery has 2 subclasses:
- SingleQuery used for sole queries not having any UNION clauses
- CombinedQuery used for queries that have at least one query combinator
(UNION in current openCypher, but other set combinators like INTERSECT
are about to come, see opencypher/openCypher#227)
```
CombinedQuery
+-singleQuery: SingleQuery S1
+-union:
+-[list entry]: Union
+-singleQuery: SingleQuery S2
+-[list entry]: Union
+-singleQuery: SingleQuery S3
```
|
This needs to be reflected here. |
This addresses #180.
View latest