Skip to content
Open
Changes from 1 commit
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
56f2d90
First early draft for Cypher support for working with multiple graphs
boggle Jun 27, 2017
ce09cf5
Reflect recent discussions
boggle Jul 1, 2017
98d78b6
Minor changes and clarifications
boggle Jul 1, 2017
4714ca6
Remove graph space notion and consolidate update semantics section
boggle Jul 3, 2017
581f192
Move into correct directory
boggle Aug 3, 2017
343ff7d
Language changes
boggle Aug 3, 2017
4cdb3dc
Clarified semantics of UNION
boggle Aug 3, 2017
a756fcf
Removed INPUT GRAPHS syntax
boggle Aug 3, 2017
71ad96e
Reworked the syntax to be a little more flexible
boggle Aug 3, 2017
be361f6
Simplified aliasing and returning graphs syntax definition
boggle Aug 4, 2017
972ceaf
Tweaked syntax as per internal discussion
boggle Aug 4, 2017
4c0d1d2
Added more meaningful titles to existing examples
Aug 4, 2017
f8fcc8e
Added first draft of detailed example
Aug 4, 2017
89b9cc6
Reformatting of image and headings
Aug 5, 2017
aef40d7
Filled in Cypher statements for writing to new graphs in large example
Aug 5, 2017
3d066a5
Formatting improvements to detailed example
Aug 5, 2017
179cb8a
Rework graph-ref/def
boggle Aug 5, 2017
ea90ffc
Switch to slightly more regular syntax
boggle Aug 6, 2017
9c134d8
Reorganized syntax for tighter control on what goes where
boggle Aug 7, 2017
82cf43b
Fixed query
boggle Aug 7, 2017
73c4a6e
Very small textual changes - round 1
Aug 7, 2017
760d433
Removed all subgraph forms from examples: `{...}`
Aug 7, 2017
003cc1d
Changed WITH semantics, made COPY a def and, introduced THEN
boggle Aug 7, 2017
5da27c8
Rename execution context to session context
boggle Aug 8, 2017
70e3b0d
Made source graph and target graph part of query context
boggle Aug 8, 2017
4eeba29
New Sales roll-up example motivating returning tabular data and graphs
Aug 8, 2017
98d7288
Sales roll-up example refinements
Aug 8, 2017
d600ccc
Sales roll-up example: full query pipeline
Aug 8, 2017
9935f70
Formatting improvements
Aug 8, 2017
53d9d09
New example: external execution context using ext. input table and graph
Aug 8, 2017
dc40338
Add collecting graph defs, projections now update source, minor edits
boggle Aug 15, 2017
5d0e97c
Projecting follow-up source and target in one go
boggle Aug 16, 2017
b7d6f08
Minor clarifications and corrections
Mats-SX Aug 17, 2017
86ffb17
Clarify and restructure Named Graphs
Mats-SX Aug 17, 2017
8aa30b5
Alteration of some relationship types in the sales graphs
Sep 25, 2017
0382582
Reformatted title
Jan 17, 2018
90f884d
Cleaned out CIP prior to updating it
boggle Mar 21, 2018
edf1e80
MPGM and identities
boggle Mar 21, 2018
31f080d
More work on MG
systay Mar 21, 2018
f2a9587
Select, construct, return graph
boggle Mar 23, 2018
d339f8d
Graph union, clarified execution result, some shuffling
boggle Mar 24, 2018
dcd22de
Reshuffled initial definitions
boggle Mar 25, 2018
39be9ca
CONSTRUCT ON GRAPH and YIELD NONE
boggle Mar 25, 2018
9cdbbf0
Clarified different forms of YIELD
boggle Mar 25, 2018
90c53ad
Restructure query execution section
boggle Mar 25, 2018
9aef639
Fixups
boggle Mar 25, 2018
f938d15
Catalog operations and some polish
boggle Apr 3, 2018
b87de21
Added alternatives
boggle Apr 3, 2018
877d6ae
Work on examples
systay Apr 4, 2018
8a65cc4
Tiny corrections
boggle Apr 4, 2018
7e96620
Clearing up definitions
boggle Apr 5, 2018
e971be4
Wrapped up the integration example
systay Apr 6, 2018
849787c
Reworked graph construction and introduced provenance
boggle Apr 9, 2018
7a99b78
Auxiliary functions
boggle Apr 10, 2018
e6a0d68
Reshuffling and tweaking
boggle Apr 10, 2018
066f444
Fixed section level
boggle Apr 10, 2018
4d2135e
Fixed tab stops
boggle Apr 10, 2018
cbb52a8
Fixups
boggle Apr 10, 2018
0b66662
Mini fixes
boggle Apr 29, 2018
2327c3b
Reworked references vs identity a bit
boggle Apr 30, 2018
4bc50dd
WIP
boggle May 1, 2018
8ff91a1
Updated definitions
boggle May 4, 2018
fa9e85f
Shuffle structure
boggle May 4, 2018
4da00d2
More structure work
boggle May 4, 2018
85c3740
Added Data model text
May 4, 2018
3df1eb8
Tiny fixes
boggle May 4, 2018
d831bfc
Clone => Replicate
boggle May 4, 2018
3af673a
Juxtaposition, simplification, introspection functions
boggle May 6, 2018
93517e5
Fixed composite statement definition
boggle May 6, 2018
cde04b7
Fix definitions around composite statements
boggle May 6, 2018
7b2237c
Polished Abstract, Intro, Data Model
May 7, 2018
a18a2a2
Removed catalog section from CIP
boggle May 7, 2018
11d9531
Polished Query structure and Execution model
May 7, 2018
bdb3df3
Added Overview subsection
May 7, 2018
fec7c6e
local declarations and simple statement chains
boggle May 7, 2018
5cc373e
Polished Basic graph operations
May 7, 2018
97cd398
Merge branch 'CIP2017-06-18-multiple-graphs-devel' of github.com:bogg…
May 7, 2018
739a435
Links in Graph construction
May 7, 2018
53257da
Polishing of Graph construction - Take I
May 7, 2018
ed1a1aa
Polishing of Graph construction - Take II
May 7, 2018
1c06ab9
Addressed TODOs
boggle May 7, 2018
d96f928
Updated image
boggle May 7, 2018
c5b8e42
Fix up errors
May 8, 2018
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
Prev Previous commit
Next Next commit
Rework graph-ref/def
  • Loading branch information
boggle committed Aug 5, 2017
commit 179cb8ae64581923f5ee0ae3268a4668fe5de495
83 changes: 35 additions & 48 deletions cip/1.accepted/CIP2017-06-18-multiple-graphs.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,10 @@ This CIP first proposes some auxiliary syntax definitions before proceeding to a

=== Graph reference

This CIP defines the notion of `<graph-reference>` as a means to introduce and refer to graphs.
This CIP defines the notion of a graph reference `<graph-ref>` as a means to refer to existing graphs.
This CIP proposes the following kinds of graph references:

* `NEW GRAPH [AT <graph-url>]`: Reference to a newly created, empty graph that may potentially overwrite any pre-existing graph at the provided `<graph-url>`
* `COPY <graph-reference> [TO <graph-url>]`: Reference to a copy of the graph referred to by `<graph-reference>`
* `GRAPH AT <graph-url>`: Reference to the graph at the given `<graph-url>`
* `GRAPH <graph-name>`: Reference to an already bound named graph
* `<graph-name>`: Reference to an already bound named graph
* `SOURCE GRAPH`: Reference to the currently _provided source graph_
* `TARGET GRAPH`: Reference to the currently _provided target graph_
* `DEFAULT GRAPH`: Reference to the _default graph_
Expand All @@ -204,49 +201,44 @@ This CIP however proposes that a `<graph-url>` must always be given as either a

This allows parameterization of queries by controlling which graphs from which graph URLs they should use.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'they' feels a bit misplaced to me. I suggest concatenating the sentences, perhaps

[...] or a query parameter, allowing a query to be parameterised on its input and output graphs.


=== Aliased graph
=== Graph definition

This CIP defines the notion of `<aliased-graph>` for describing the aliasing of graphs.
An `<aliased-graph>` is a `<graph-reference>` that may optionally be followed by `AS <new-graph-name>`.
This CIP defines the notion of a graph definition `<graph-def>` for describing the introduction and aliasing of new named graphs.
A `<graph-def>` may have one of the following forms:

The alias of an `<aliased-graph>` is either the explicitly given `<new-graph-name>` if present or an implicit fresh system generated name otherwise.
It is an error to use an `<aliased-graph>` in a context where its introduced `<new-graph-name>` is already bound.
* `<graph-ref> [AS <new-graph-name>]`: Reference to an existing graph
* `NEW GRAPH [<new-graph-name>] [AT <graph-url>]`: Introduce a newly created, empty graph that is to be made available at the provided `<graph-url>`
* `COPY <graph-reference> [TO <graph-url>] [AS <new-graph-name>]`: Introduce a copy of the graph referred to by provided `<graph-reference>`
* `GRAPH <new-graph-name> AT <graph-url>`: Load and introduce the graph that is available at the provided `<graph-url>`

`NEW GRAPH <new-graph-name> [AT <graph-url>]` is proposed as a shorthand for `NEW GRAPH [AT <graph-url>] AS <new-graph-name>`.

`GRAPH <new-graph-name> AT <graph-url>` is proposed as a shorthand for `GRAPH AT <graph-url> AS <new-graph-name>`.
The alias of a `<graph-def>` is either the explicitly given `<new-graph-name>` if present or an implicit fresh system generated name otherwise.
It is an error to use a `<graph-def>` in a context where its introduced `<new-graph-name>` is already bound.

=== Changing query context graphs

As a first language addition, this CIP proposes syntax for changing the source and the target graph of the current query context:

[source, cypher]
----
FROM < aliased-graph >
FROM < graph-name > [AS < new-graph-name >]
FROM < graph-def >
FROM -
INTO < aliased-graph >
INTO < graph-name > [AS < new-graph-name >]
INTO < graph-def >
INTO -
----

==== FROM clause

The newly introduced `FROM` clause may be used to change both the source and the target graph of the current query context to the graph described by the given `<aliased-graph>`.

`FROM <graph-name> [AS <new-graph-name>]` is a shorthand for `FROM GRAPH <graph-name> [AS <new-graph-name>]`.
The newly introduced `FROM` clause may be used to change both the source and the target graph of the current query context to the graph described by the given `<graph-def>`.

`FROM` always binds the referenced graph of the `<aliased-graph>` to its alias.
`FROM` always binds the referenced graph of the `<graph-def>` to its alias.

`FROM -` may be used to discard the current source and the current target graph.

==== INTO clause

The newly introduced `INTO` clause may be used to change the target graph of the current query context to the graph described by the given `<aliased-graph>`.
The newly introduced `INTO` clause may be used to change the target graph of the current query context to the graph described by the given `<graph-def>`.

`INTO` always binds the referenced graph of the `<aliased-graph>` to its alias.

`INTO <graph-name> [AS <new-graph-name>]` is a shorthand for `INTO GRAPH <graph-name> [AS <new-graph-name>]`.
`INTO` always binds the referenced graph of the `<graph-def>` to its alias.

`INTO -` may be used to discard the current target graph.

Expand All @@ -261,18 +253,13 @@ WITH < return-items > [ < graph-return-items > ]
RETURN < return-items > [ < graph-return-items > ]
----

This CIP defines that `<graph-return-items>` is a non-empty, comma separated list of `<graph-return-item>` that describes which graphs are to be passed on.

This CIP defines that each `<graph-return-item>` is one of:
This CIP defines that `<graph-return-items>` is one of:

* `GRAPHS *`: All named graphs currently in scope are to be passed on
* `GRAPHS <graph-alias-list>`: All explicitly listed graphs are to be passed on.
* `GRAPHS *, <graph-alias-list>`: All named graphs currently in scope together with any additionally introduced aliases rom `<graph-alias-list>` are to be passed on
* `<graph-alias>`: A single graph alias is to be passed on
* `GRAPHS <graph-def-list>`: All explicitly listed graphs are to be passed on.
* `GRAPHS *, <graph-def-list>`: All named graphs currently in scope together with any additionally introduced named graphs from `<graph-def-list>` are to be passed on

`GRAPHS *` and `GRAPHS *, <graph-alias-list>` may only be used as the first `<graph-return-item>`.

This CIP defines `<graph-alias-list>` as a non-empty, comma separated list of names of graphs that are currently in scope that each may optionally be followed by an alias of the form `AS <new-graph-name>`.
This CIP defines `<graph-def-list>` as a non-empty, comma separated list of `<graph-def>`.

The order of named graphs inherently given by `<graph-return-items>` is semantically insignificant.
However it is recommended that conforming implementations preserve this order at least in programmatic output operations (e.g. a textual display of the list of returned graphs).
Expand Down Expand Up @@ -309,8 +296,8 @@ The proposed syntax is:

[source, cypher]
----
FROM < aliased-graph > | < graph-name > [ AS < new-graph-name > ] | - { < graph-construction-subquery > }
INTO < aliased-graph > | < graph-name > [ AS < new-graph-name > ] | - { < graph-construction-subquery > }
FROM < graph-def > | - { < graph-construction-subquery > }
INTO < graph-def > | - { < graph-construction-subquery > }
----

A `<graph-construction-subquery>` is an updating subquery (i.e. a sequence of clauses, including update clauses) that may or may not end in `RETURN`.
Expand Down Expand Up @@ -383,7 +370,7 @@ RETURN c, d GRAPHS g5 // Third query over second query over first query

[source, cypher]
----
FROM GRAPH persons AT 'graph://...'
FROM persons AT 'graph://...'
MATCH (a:Person)-[r:KNOWS]->(b:Person)
MATCH (a)-[:LIVES_IN->(c:City)<-[:LIVES_IN]-(b)
INTO NEW GRAPH berlin
Expand Down Expand Up @@ -411,7 +398,7 @@ CREATE (a)-[:POSSIBLE_FRIEND]->(c)
WITH GRAPHS *

// Switch context to named graph.
FROM GRAPH recommendations
FROM recommendations
MATCH (a:Person)-[e:POSSIBLE_FRIEND]->(b:Person)
// Return tabular and graph output
RETURN a.name, b.name, count(e) AS cnt
Expand Down Expand Up @@ -439,7 +426,7 @@ SET a.country = cn.name
// ... and finally discard all tabular data and cardinality
WITH GRAPHS *

FROM GRAPH sn_updated
FROM sn_updated
MATCH (a:Person)-[e:KNOWS]->(b:Person)
WITH a.country AS a_country, b.country AS b_country, count(a) AS a_cnt, count(b) AS b_cnt, count(e) AS e_cnt
INTO NEW GRAPH rollup {
Expand Down Expand Up @@ -479,7 +466,7 @@ INTO NEW GRAPH german_people AT './ger' {
WITH GRAPHS *

// Start query on the 'sweden_people' graph
FROM GRAPH sweden_people
FROM sweden_people
MATCH p=(a)--(b)--(c)--(a) WHERE NOT (a)--(c)
// Create a temporary graph 'swedish_triangles'
INTO NEW GRAPH swedish_triangles {
Expand Down Expand Up @@ -604,7 +591,7 @@ The target graph is set to the *PersonCityEvents* graph (created earlier):

[source, cypher]
----
INTO GRAPH PersonCityEvents
INTO PersonCityEvents
----

Using the results from the `MATCH` clause, create a subgraph with more intelligible semantics through the transformation of the events information into a less verbose form through greater use of node-level properties.
Expand Down Expand Up @@ -632,7 +619,7 @@ MATCH (c)<-[:IN_CITY]-(e)-[:IN_YEAR]->(y),

//Do matches for all other event types: Public Event, War Event....
...
INTO GRAPH PersonCityEvents {
INTO PersonCityEvents {
MERGE (c:City {name: c.value})
MERGE (e {title: e.value, year: y.value})
MERGE (e)-[:HAPPENED_IN]->(c)
Expand All @@ -657,7 +644,7 @@ Set *PersonCityEvents* to be in scope:

[source, cypher]
----
FROM GRAPH PersonCityEvents
FROM PersonCityEvents
----

Next, obtain the subgraph of all criminal events -- i.e. nodes labelled with `CriminalEvent` -- and their associated `City` nodes, and `Person` nodes associated with the `City` nodes:
Expand Down Expand Up @@ -690,7 +677,7 @@ Putting all these statements together, we get:
_Query sequence for Step 3_:
[source, cypher]
----
FROM GRAPH PersonCityEvents
FROM PersonCityEvents
MATCH (ce:CriminalEvent)-[:HAPPENED_IN]->(c:City)<-[:BORN_IN]-(p:Person)
INTO NEW GRAPH Temp-PersonCityCrimes {
MERGE (p:Person {name: p.name, YOB: p.YOB})
Expand Down Expand Up @@ -726,7 +713,7 @@ MATCH (c)<-[:IN_CITY]-(e)-[:IN_YEAR]->(y),

//Do matches for all other event types: Public Event, War Event....
...
INTO GRAPH PersonCityEvents {
INTO PersonCityEvents {
MERGE (c:City {name: c.value})
MERGE (e {title: e.value, year: y.value})
MERGE (e)-[:HAPPENED_IN]->(c)
Expand All @@ -735,9 +722,9 @@ INTO GRAPH PersonCityEvents {
//Do for all remaining event types
...
}
WITH GRAPH *
WITH GRAPHS *

FROM GRAPH PersonCityEvents
FROM PersonCityEvents
MATCH (ce:CriminalEvent)-[:HAPPENED_IN]->(c:City)<-[:BORN_IN]-(p:Person)
INTO NEW GRAPH Temp-PersonCityCrimes {
MERGE (p:Person {name: p.name, YOB: p.YOB})
Expand All @@ -746,7 +733,7 @@ INTO NEW GRAPH Temp-PersonCityCrimes {
MERGE (p)-[:BORN_IN]->(c)
MERGE (ce)-[:HAPPENED_IN]->(c)
}
RETURN GRAPH Temp-PersonCityCrimes
RETURN GRAPHS Temp-PersonCityCrimes
----

== Interaction with existing features
Expand Down