Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Formal Specification of Cypher
Nadime Francis
University of Edinburgh
Wednesday, May, 10th
1 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Property Graphs
Person, Postdoc
name : ‘Nadime’
institute : ‘UoE’
Person, Professor
name : ‘Leonid’
institute : ‘UoE’
knows
since : 2010
colleague
since : 2015
A property graph is a tuple G = (N, R, s, t, ι, λ, τ), where:
N ⊆ N: finite set of nodes
R ⊆ R: finite set of relationships
s : R → N: maps each relationship to its source
t : R → N: maps each relationship to its target
ι : (N ∪ R) × K → V: maps each x and k to x.k.
λ : N → 2L: associates a set of label to each node
τ : R → T : associates a type to each relationship
2 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Records and Tables
A record is a tuple with named fields : (a1 : v1, . . . , an : vn).
A table is a bag of uniform records.
Example:
(a : 1, b : 3), (a : ‘oCIM 2’, b : ‘London’),
(a : ‘oCIM’, b : ‘Walldorf’), (a : 1, b : 3)
a b
1 3
‘oCIM 2’ ‘London’
‘oCIM’ ‘Walldorf’
1 3
=
a b
‘oCIM’ ‘Walldorf’
1 3
‘oCIM 2’ ‘London’
1 3
3 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Operations and Expressions
An Example
MATCH (n : Person) − [: knows]−> (m : Person)
WHERE n.institute = m.institute
RETURN n.name, m.name, n.institute AS institute
4 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Operations and Expressions
An Example
MATCH (n : Person) − [: knows]−> (m : Person)
WHERE n.institute = m.institute
RETURN n.name, m.name, n.institute AS institute
4 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Operations and Expressions
An Example
MATCH (n : Person) − [: knows]−> (m : Person)
WHERE n.institute = m.institute
RETURN n.name, m.name, n.institute AS institute
n m
{name : ‘Nadime’, institute : ‘UoE’} {name : ‘Leonid’, institute : ‘UoE’}
{name : ‘Paolo’, institute : ‘UoE’} {name : ‘Nadime’, institute : ‘UoE’}
{name : ‘Nadime’, institute : ‘UoE’} {name : ‘Stefan’, institute : ‘Neo’}
{name : ‘Alastair’, institute : ‘Neo’} {name : ‘Stefan’, institute : ‘Neo’}
4 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Operations and Expressions
An Example
MATCH (n : Person) − [: knows]−> (m : Person)
WHERE n.institute = m.institute
RETURN n.name, m.name, n.institute AS institute
n m
{name : ‘Nadime’, institute : ‘UoE’} {name : ‘Leonid’, institute : ‘UoE’}
{name : ‘Paolo’, institute : ‘UoE’} {name : ‘Nadime’, institute : ‘UoE’}
{name : ‘Alastair’, institute : ‘Neo’} {name : ‘Stefan’, institute : ‘Neo’}
4 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Operations and Expressions
An Example
MATCH (n : Person) − [: knows]−> (m : Person)
WHERE n.institute = m.institute
RETURN n.name, m.name, n.institute AS institute
n.name m.name institute
‘Nadime’ ‘Leonid’ UoE
‘Paolo’ ‘Nadime’ UoE
‘Alastair’ ‘Stefan’ Neo
4 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Operations and Expressions
Q =
(α) MATCH (n : Person) − [: knows]−> (m : Person)
(β) WHERE n.institute = m.institute
(γ) RETURN n.name, m.name, n.institute AS institute
5 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Operations and Expressions
Q =
(α) MATCH (n : Person) − [: knows]−> (m : Person)
(β) WHERE n.institute = m.institute
(γ) RETURN n.name, m.name, n.institute AS institute
Operations
[[op]]G : Tables → Tables
Semantics of a query by composition
Ex: [[Q]]G = [[α]]G ◦ [[β]]G ◦ [[γ]]G
Answers to Q on G: [[Q]]G ({})
5 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Operations and Expressions
Q =
(α) MATCH (n : Person) − [: knows]−> (m : Person)
(β) WHERE n.institute = m.institute
(γ) RETURN n.name, m.name, n.institute AS institute
Operations
[[op]]G : Tables → Tables
Semantics of a query by composition
Ex: [[Q]]G = [[α]]G ◦ [[β]]G ◦ [[γ]]G
Answers to Q on G: [[Q]]G ({})
Expressions
[[exp]]G,u ∈ V where u is a record, giving binding to variables
Ex: [[β]]G (T) = u ∈ T | [[n.institute = m.institute]]G,u = true
5 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Pattern Matching
Rigid pattern satisfaction
Rigid path pattern: no variable length edge patterns.
Ex: (n : Person) − [: knows ∗ 2]−> () − [: likes]−> (m : Movie)
Unique way for a path p to satisfy a rigid pattern π wrt G, u.
Notation: (p, G, u) |= π
6 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Pattern Matching
Rigid pattern satisfaction
Rigid path pattern: no variable length edge patterns.
Ex: (n : Person) − [: knows ∗ 2]−> () − [: likes]−> (m : Movie)
Unique way for a path p to satisfy a rigid pattern π wrt G, u.
Notation: (p, G, u) |= π
Variable-length paths and free variables
rigid(π) = {π | π is rigid and π π }
Ex: () − [∗2]−> () − [∗4]−> () () − [∗1..3]−> () − [∗]−> ()
free(π, u): all names that occur in π and not in u
6 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Pattern Matching
Rigid pattern satisfaction
Rigid path pattern: no variable length edge patterns.
Ex: (n : Person) − [: knows ∗ 2]−> () − [: likes]−> (m : Movie)
Unique way for a path p to satisfy a rigid pattern π wrt G, u.
Notation: (p, G, u) |= π
Variable-length paths and free variables
rigid(π) = {π | π is rigid and π π }
Ex: () − [∗2]−> () − [∗4]−> () () − [∗1..3]−> () − [∗]−> ()
free(π, u): all names that occur in π and not in u
[[MATCH π]]G (T) =
π ∈rigid(π)
u∈T, p∈paths
(u, u )
u is uniform with free(π , u)
and (p, G, (u, u )) |= π
6 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Ambiguous and Edge Cases
7 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Nulls in Patterns
MATCH (n : Person {name : null})
RETURN (n)
8 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Nulls in Patterns
MATCH (n : Person {name : null})
RETURN (n)
1 Every node n with a name property?
2 Every node n such that n.name IS NULL = true?
3 Nothing?
8 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Nulls in Patterns
MATCH (n : Person {name : null})
RETURN (n)
1 Every node n with a name property?
2 Every node n such that n.name IS NULL = true?
3 Nothing!
Because Q is actually equivalent to:
MATCH (n : Person)
WHERE n.name = null
RETURN (n)
8 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Map Comparisons
When does {k1 : v1, . . . , kn : vn} = { 1 : w1, . . . , m : wm} return
true, false or null?
{name : null} = {}
{name : null} = {name : null}
{a : 1, b : 2} = {b : 2, a : 1}
{a : 1, a : 2} = {a : 2}
9 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Map Comparisons
When does {k1 : v1, . . . , kn : vn} = { 1 : w1, . . . , m : wm} return
true, false or null?
false
{name : null} = {}
true
{name : null} = {name : null}
true
{a : 1, b : 2} = {b : 2, a : 1}
true
{a : 1, a : 2} = {a : 2}
Neither purely syntactic, nor ∀k, m1.k = m2.k.
9 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Setting Properties using a Map
WITH {name : null} AS map
CREATE (n)
SET n = map
RETURN (n)
10 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Setting Properties using a Map
WITH {name : null} AS map
CREATE (n)
SET n = map
RETURN (n)
Returns n as {}.
The property map of n is not equal to the map it was set to.
In particular, n {.∗} = map returns false.
10 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
MATCH with no Free Variables
MATCH ()
RETURN ∗
MATCH ()
RETURN 1
11 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
MATCH with no Free Variables
Fail
MATCH ()
RETURN ∗
RETURN ∗ is not allowed with
no variable in scope.
Pass
MATCH ()
RETURN 1
Returns as many copies of 1
as nodes in the database.
After MATCH (), the active table is a bag containing multiple copies
of the empty record.
11 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Incomplete and Inconsistent Cases
12 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Repeating UNWINDs
UNWIND [1, 2, 3] AS r
UNWIND r AS s
RETURN s
UNWIND [[1, 2], 3] AS r
UNWIND r AS s
RETURN s
13 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Repeating UNWINDs
Fail
UNWIND [1, 2, 3] AS r
UNWIND r AS s
RETURN s
Type mismatch, expected List
but was Integer.
Pass
UNWIND [[1, 2], 3] AS r
UNWIND r AS s
RETURN s
Returns a column with 1, 2
and 3 as rows.
13 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Repeating UNWINDs
Fail
UNWIND [1, 2, 3] AS r
UNWIND r AS s
RETURN s
Type mismatch, expected List
but was Integer.
Pass
UNWIND [[1, 2], 3] AS r
UNWIND r AS s
RETURN s
Returns a column with 1, 2
and 3 as rows.
UNWIND [[1, 2], 3] AS r
UNWIND r AS s
UNWIND s AS t
UNWIND t AS u
RETURN u
Actually works, and returns a column with 1, 2 and 3 as rows.
13 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Violating Cyphermorphism
Q0 =
MATCH (x) − [r] − (y) − [r] − (z)
RETURN x, y, z
14 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Violating Cyphermorphism
Q0 =
MATCH (x) − [r] − (y) − [r] − (z)
RETURN x, y, z
Error: cannot use the same relationship variable ‘r’ for multiple
patterns.
14 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Violating Cyphermorphism
Q0 =
MATCH (x) − [r] − (y) − [r] − (z)
RETURN x, y, z
Error: cannot use the same relationship variable ‘r’ for multiple
patterns.
Q1 =
MATCH (x) − [r∗] − (y) − [r∗] − (z)
RETURN x, y, z
14 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Violating Cyphermorphism
Q0 =
MATCH (x) − [r] − (y) − [r] − (z)
RETURN x, y, z
Error: cannot use the same relationship variable ‘r’ for multiple
patterns.
Q1 =
MATCH (x) − [r∗] − (y) − [r∗] − (z)
RETURN x, y, z
Works and enforces the paths from x to y and from y to z to use
the same sequence of relationships, violating Cyphermorphism.
14 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Violating Cyphermorphism
Q0 =
MATCH (x) − [r] − (y) − [r] − (z)
RETURN x, y, z
Error: cannot use the same relationship variable ‘r’ for multiple
patterns.
Q1 =
MATCH (x) − [r∗] − (y) − [r∗] − (z)
RETURN x, y, z
Works and enforces the paths from x to y and from y to z to use
the same sequence of relationships, violating Cyphermorphism.
It is not included in the query Q2 below:
Q1 =
MATCH (x) − [r∗] − (y) − [s∗] − (z)
RETURN x, y, z
14 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Two Small Issues: Nulls as Indices and Keys, and Naming
RETURN 1 AS ‘0‘, 0
15 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Two Small Issues: Nulls as Indices and Keys, and Naming
Fail
RETURN 1 AS ‘0‘, 0
Multiple result columns with the same name are not supported.
Need to specify how expression naming is handled.
15 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Two Small Issues: Nulls as Indices and Keys, and Naming
Fail
RETURN 1 AS ‘0‘, 0
Multiple result columns with the same name are not supported.
Need to specify how expression naming is handled.
[1, 2, 3][null] [1, 2, 3][null..4]
{name : ‘Nadime’} [null]
15 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Two Small Issues: Nulls as Indices and Keys, and Naming
Fail
RETURN 1 AS ‘0‘, 0
Multiple result columns with the same name are not supported.
Need to specify how expression naming is handled.
Fail
[1, 2, 3][null] [1, 2, 3][null..4]
{name : ‘Nadime’} [null]
No error, never terminates.
15 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Thank you!
16 / 16

Formal Specification of Cypher

  • 1.
    Semantics Overview Ambiguousand Edge Cases Incomplete and Inconsistent Cases Formal Specification of Cypher Nadime Francis University of Edinburgh Wednesday, May, 10th 1 / 16
  • 2.
    Semantics Overview Ambiguousand Edge Cases Incomplete and Inconsistent Cases Property Graphs Person, Postdoc name : ‘Nadime’ institute : ‘UoE’ Person, Professor name : ‘Leonid’ institute : ‘UoE’ knows since : 2010 colleague since : 2015 A property graph is a tuple G = (N, R, s, t, ι, λ, τ), where: N ⊆ N: finite set of nodes R ⊆ R: finite set of relationships s : R → N: maps each relationship to its source t : R → N: maps each relationship to its target ι : (N ∪ R) × K → V: maps each x and k to x.k. λ : N → 2L: associates a set of label to each node τ : R → T : associates a type to each relationship 2 / 16
  • 3.
    Semantics Overview Ambiguousand Edge Cases Incomplete and Inconsistent Cases Records and Tables A record is a tuple with named fields : (a1 : v1, . . . , an : vn). A table is a bag of uniform records. Example: (a : 1, b : 3), (a : ‘oCIM 2’, b : ‘London’), (a : ‘oCIM’, b : ‘Walldorf’), (a : 1, b : 3) a b 1 3 ‘oCIM 2’ ‘London’ ‘oCIM’ ‘Walldorf’ 1 3 = a b ‘oCIM’ ‘Walldorf’ 1 3 ‘oCIM 2’ ‘London’ 1 3 3 / 16
  • 4.
    Semantics Overview Ambiguousand Edge Cases Incomplete and Inconsistent Cases Operations and Expressions An Example MATCH (n : Person) − [: knows]−> (m : Person) WHERE n.institute = m.institute RETURN n.name, m.name, n.institute AS institute 4 / 16
  • 5.
    Semantics Overview Ambiguousand Edge Cases Incomplete and Inconsistent Cases Operations and Expressions An Example MATCH (n : Person) − [: knows]−> (m : Person) WHERE n.institute = m.institute RETURN n.name, m.name, n.institute AS institute 4 / 16
  • 6.
    Semantics Overview Ambiguousand Edge Cases Incomplete and Inconsistent Cases Operations and Expressions An Example MATCH (n : Person) − [: knows]−> (m : Person) WHERE n.institute = m.institute RETURN n.name, m.name, n.institute AS institute n m {name : ‘Nadime’, institute : ‘UoE’} {name : ‘Leonid’, institute : ‘UoE’} {name : ‘Paolo’, institute : ‘UoE’} {name : ‘Nadime’, institute : ‘UoE’} {name : ‘Nadime’, institute : ‘UoE’} {name : ‘Stefan’, institute : ‘Neo’} {name : ‘Alastair’, institute : ‘Neo’} {name : ‘Stefan’, institute : ‘Neo’} 4 / 16
  • 7.
    Semantics Overview Ambiguousand Edge Cases Incomplete and Inconsistent Cases Operations and Expressions An Example MATCH (n : Person) − [: knows]−> (m : Person) WHERE n.institute = m.institute RETURN n.name, m.name, n.institute AS institute n m {name : ‘Nadime’, institute : ‘UoE’} {name : ‘Leonid’, institute : ‘UoE’} {name : ‘Paolo’, institute : ‘UoE’} {name : ‘Nadime’, institute : ‘UoE’} {name : ‘Alastair’, institute : ‘Neo’} {name : ‘Stefan’, institute : ‘Neo’} 4 / 16
  • 8.
    Semantics Overview Ambiguousand Edge Cases Incomplete and Inconsistent Cases Operations and Expressions An Example MATCH (n : Person) − [: knows]−> (m : Person) WHERE n.institute = m.institute RETURN n.name, m.name, n.institute AS institute n.name m.name institute ‘Nadime’ ‘Leonid’ UoE ‘Paolo’ ‘Nadime’ UoE ‘Alastair’ ‘Stefan’ Neo 4 / 16
  • 9.
    Semantics Overview Ambiguousand Edge Cases Incomplete and Inconsistent Cases Operations and Expressions Q = (α) MATCH (n : Person) − [: knows]−> (m : Person) (β) WHERE n.institute = m.institute (γ) RETURN n.name, m.name, n.institute AS institute 5 / 16
  • 10.
    Semantics Overview Ambiguousand Edge Cases Incomplete and Inconsistent Cases Operations and Expressions Q = (α) MATCH (n : Person) − [: knows]−> (m : Person) (β) WHERE n.institute = m.institute (γ) RETURN n.name, m.name, n.institute AS institute Operations [[op]]G : Tables → Tables Semantics of a query by composition Ex: [[Q]]G = [[α]]G ◦ [[β]]G ◦ [[γ]]G Answers to Q on G: [[Q]]G ({}) 5 / 16
  • 11.
    Semantics Overview Ambiguousand Edge Cases Incomplete and Inconsistent Cases Operations and Expressions Q = (α) MATCH (n : Person) − [: knows]−> (m : Person) (β) WHERE n.institute = m.institute (γ) RETURN n.name, m.name, n.institute AS institute Operations [[op]]G : Tables → Tables Semantics of a query by composition Ex: [[Q]]G = [[α]]G ◦ [[β]]G ◦ [[γ]]G Answers to Q on G: [[Q]]G ({}) Expressions [[exp]]G,u ∈ V where u is a record, giving binding to variables Ex: [[β]]G (T) = u ∈ T | [[n.institute = m.institute]]G,u = true 5 / 16
  • 12.
    Semantics Overview Ambiguousand Edge Cases Incomplete and Inconsistent Cases Pattern Matching Rigid pattern satisfaction Rigid path pattern: no variable length edge patterns. Ex: (n : Person) − [: knows ∗ 2]−> () − [: likes]−> (m : Movie) Unique way for a path p to satisfy a rigid pattern π wrt G, u. Notation: (p, G, u) |= π 6 / 16
  • 13.
    Semantics Overview Ambiguousand Edge Cases Incomplete and Inconsistent Cases Pattern Matching Rigid pattern satisfaction Rigid path pattern: no variable length edge patterns. Ex: (n : Person) − [: knows ∗ 2]−> () − [: likes]−> (m : Movie) Unique way for a path p to satisfy a rigid pattern π wrt G, u. Notation: (p, G, u) |= π Variable-length paths and free variables rigid(π) = {π | π is rigid and π π } Ex: () − [∗2]−> () − [∗4]−> () () − [∗1..3]−> () − [∗]−> () free(π, u): all names that occur in π and not in u 6 / 16
  • 14.
    Semantics Overview Ambiguousand Edge Cases Incomplete and Inconsistent Cases Pattern Matching Rigid pattern satisfaction Rigid path pattern: no variable length edge patterns. Ex: (n : Person) − [: knows ∗ 2]−> () − [: likes]−> (m : Movie) Unique way for a path p to satisfy a rigid pattern π wrt G, u. Notation: (p, G, u) |= π Variable-length paths and free variables rigid(π) = {π | π is rigid and π π } Ex: () − [∗2]−> () − [∗4]−> () () − [∗1..3]−> () − [∗]−> () free(π, u): all names that occur in π and not in u [[MATCH π]]G (T) = π ∈rigid(π) u∈T, p∈paths (u, u ) u is uniform with free(π , u) and (p, G, (u, u )) |= π 6 / 16
  • 15.
    Semantics Overview Ambiguousand Edge Cases Incomplete and Inconsistent Cases Ambiguous and Edge Cases 7 / 16
  • 16.
    Semantics Overview Ambiguousand Edge Cases Incomplete and Inconsistent Cases Nulls in Patterns MATCH (n : Person {name : null}) RETURN (n) 8 / 16
  • 17.
    Semantics Overview Ambiguousand Edge Cases Incomplete and Inconsistent Cases Nulls in Patterns MATCH (n : Person {name : null}) RETURN (n) 1 Every node n with a name property? 2 Every node n such that n.name IS NULL = true? 3 Nothing? 8 / 16
  • 18.
    Semantics Overview Ambiguousand Edge Cases Incomplete and Inconsistent Cases Nulls in Patterns MATCH (n : Person {name : null}) RETURN (n) 1 Every node n with a name property? 2 Every node n such that n.name IS NULL = true? 3 Nothing! Because Q is actually equivalent to: MATCH (n : Person) WHERE n.name = null RETURN (n) 8 / 16
  • 19.
    Semantics Overview Ambiguousand Edge Cases Incomplete and Inconsistent Cases Map Comparisons When does {k1 : v1, . . . , kn : vn} = { 1 : w1, . . . , m : wm} return true, false or null? {name : null} = {} {name : null} = {name : null} {a : 1, b : 2} = {b : 2, a : 1} {a : 1, a : 2} = {a : 2} 9 / 16
  • 20.
    Semantics Overview Ambiguousand Edge Cases Incomplete and Inconsistent Cases Map Comparisons When does {k1 : v1, . . . , kn : vn} = { 1 : w1, . . . , m : wm} return true, false or null? false {name : null} = {} true {name : null} = {name : null} true {a : 1, b : 2} = {b : 2, a : 1} true {a : 1, a : 2} = {a : 2} Neither purely syntactic, nor ∀k, m1.k = m2.k. 9 / 16
  • 21.
    Semantics Overview Ambiguousand Edge Cases Incomplete and Inconsistent Cases Setting Properties using a Map WITH {name : null} AS map CREATE (n) SET n = map RETURN (n) 10 / 16
  • 22.
    Semantics Overview Ambiguousand Edge Cases Incomplete and Inconsistent Cases Setting Properties using a Map WITH {name : null} AS map CREATE (n) SET n = map RETURN (n) Returns n as {}. The property map of n is not equal to the map it was set to. In particular, n {.∗} = map returns false. 10 / 16
  • 23.
    Semantics Overview Ambiguousand Edge Cases Incomplete and Inconsistent Cases MATCH with no Free Variables MATCH () RETURN ∗ MATCH () RETURN 1 11 / 16
  • 24.
    Semantics Overview Ambiguousand Edge Cases Incomplete and Inconsistent Cases MATCH with no Free Variables Fail MATCH () RETURN ∗ RETURN ∗ is not allowed with no variable in scope. Pass MATCH () RETURN 1 Returns as many copies of 1 as nodes in the database. After MATCH (), the active table is a bag containing multiple copies of the empty record. 11 / 16
  • 25.
    Semantics Overview Ambiguousand Edge Cases Incomplete and Inconsistent Cases Incomplete and Inconsistent Cases 12 / 16
  • 26.
    Semantics Overview Ambiguousand Edge Cases Incomplete and Inconsistent Cases Repeating UNWINDs UNWIND [1, 2, 3] AS r UNWIND r AS s RETURN s UNWIND [[1, 2], 3] AS r UNWIND r AS s RETURN s 13 / 16
  • 27.
    Semantics Overview Ambiguousand Edge Cases Incomplete and Inconsistent Cases Repeating UNWINDs Fail UNWIND [1, 2, 3] AS r UNWIND r AS s RETURN s Type mismatch, expected List but was Integer. Pass UNWIND [[1, 2], 3] AS r UNWIND r AS s RETURN s Returns a column with 1, 2 and 3 as rows. 13 / 16
  • 28.
    Semantics Overview Ambiguousand Edge Cases Incomplete and Inconsistent Cases Repeating UNWINDs Fail UNWIND [1, 2, 3] AS r UNWIND r AS s RETURN s Type mismatch, expected List but was Integer. Pass UNWIND [[1, 2], 3] AS r UNWIND r AS s RETURN s Returns a column with 1, 2 and 3 as rows. UNWIND [[1, 2], 3] AS r UNWIND r AS s UNWIND s AS t UNWIND t AS u RETURN u Actually works, and returns a column with 1, 2 and 3 as rows. 13 / 16
  • 29.
    Semantics Overview Ambiguousand Edge Cases Incomplete and Inconsistent Cases Violating Cyphermorphism Q0 = MATCH (x) − [r] − (y) − [r] − (z) RETURN x, y, z 14 / 16
  • 30.
    Semantics Overview Ambiguousand Edge Cases Incomplete and Inconsistent Cases Violating Cyphermorphism Q0 = MATCH (x) − [r] − (y) − [r] − (z) RETURN x, y, z Error: cannot use the same relationship variable ‘r’ for multiple patterns. 14 / 16
  • 31.
    Semantics Overview Ambiguousand Edge Cases Incomplete and Inconsistent Cases Violating Cyphermorphism Q0 = MATCH (x) − [r] − (y) − [r] − (z) RETURN x, y, z Error: cannot use the same relationship variable ‘r’ for multiple patterns. Q1 = MATCH (x) − [r∗] − (y) − [r∗] − (z) RETURN x, y, z 14 / 16
  • 32.
    Semantics Overview Ambiguousand Edge Cases Incomplete and Inconsistent Cases Violating Cyphermorphism Q0 = MATCH (x) − [r] − (y) − [r] − (z) RETURN x, y, z Error: cannot use the same relationship variable ‘r’ for multiple patterns. Q1 = MATCH (x) − [r∗] − (y) − [r∗] − (z) RETURN x, y, z Works and enforces the paths from x to y and from y to z to use the same sequence of relationships, violating Cyphermorphism. 14 / 16
  • 33.
    Semantics Overview Ambiguousand Edge Cases Incomplete and Inconsistent Cases Violating Cyphermorphism Q0 = MATCH (x) − [r] − (y) − [r] − (z) RETURN x, y, z Error: cannot use the same relationship variable ‘r’ for multiple patterns. Q1 = MATCH (x) − [r∗] − (y) − [r∗] − (z) RETURN x, y, z Works and enforces the paths from x to y and from y to z to use the same sequence of relationships, violating Cyphermorphism. It is not included in the query Q2 below: Q1 = MATCH (x) − [r∗] − (y) − [s∗] − (z) RETURN x, y, z 14 / 16
  • 34.
    Semantics Overview Ambiguousand Edge Cases Incomplete and Inconsistent Cases Two Small Issues: Nulls as Indices and Keys, and Naming RETURN 1 AS ‘0‘, 0 15 / 16
  • 35.
    Semantics Overview Ambiguousand Edge Cases Incomplete and Inconsistent Cases Two Small Issues: Nulls as Indices and Keys, and Naming Fail RETURN 1 AS ‘0‘, 0 Multiple result columns with the same name are not supported. Need to specify how expression naming is handled. 15 / 16
  • 36.
    Semantics Overview Ambiguousand Edge Cases Incomplete and Inconsistent Cases Two Small Issues: Nulls as Indices and Keys, and Naming Fail RETURN 1 AS ‘0‘, 0 Multiple result columns with the same name are not supported. Need to specify how expression naming is handled. [1, 2, 3][null] [1, 2, 3][null..4] {name : ‘Nadime’} [null] 15 / 16
  • 37.
    Semantics Overview Ambiguousand Edge Cases Incomplete and Inconsistent Cases Two Small Issues: Nulls as Indices and Keys, and Naming Fail RETURN 1 AS ‘0‘, 0 Multiple result columns with the same name are not supported. Need to specify how expression naming is handled. Fail [1, 2, 3][null] [1, 2, 3][null..4] {name : ‘Nadime’} [null] No error, never terminates. 15 / 16
  • 38.
    Semantics Overview Ambiguousand Edge Cases Incomplete and Inconsistent Cases Thank you! 16 / 16