openCypher TCK Andrs Zsmboki , Gbor Szrnyas, Jzsef Marton TCK - - PowerPoint PPT Presentation

opencypher tck
SMART_READER_LITE
LIVE PREVIEW

openCypher TCK Andrs Zsmboki , Gbor Szrnyas, Jzsef Marton TCK - - PowerPoint PPT Presentation

openCypher TCK Andrs Zsmboki , Gbor Szrnyas, Jzsef Marton TCK Overview openCypher TCK The project aims to deliver four types of artifacts: 1. Cypher Reference Documentation 2. Grammar specification 3. TCK (Technology Compatibility


slide-1
SLIDE 1
  • penCypher TCK

András Zsámboki, Gábor Szárnyas, József Marton

slide-2
SLIDE 2

TCK Overview

slide-3
SLIDE 3
  • penCypher TCK

The project aims to deliver four types of artifacts:

  • 1. Cypher Reference Documentation
  • 2. Grammar specification
  • 3. TCK (Technology Compatibility Kit)
  • 4. Cypher language specification
slide-4
SLIDE 4
  • penCypher TCK

The project aims to deliver four types of artifacts:

  • 1. Cypher Reference Documentation
  • 2. Grammar specification
  • 3. TCK (Technology Compatibility Kit)
  • 4. Cypher language specification
slide-5
SLIDE 5

Cucumber tests

Scenario: Find all nodes Given an empty graph And having executed: """ CREATE ({name: 'a'}), ({name: 'b'}) """ When executing query: """ MATCH (n) RETURN n """ Then the result should be: | n | | ({name: 'a'}) | | ({name: 'b'}) | And no side effects

slide-6
SLIDE 6

Cucumber tests

Scenario: Find all nodes Given an empty graph And having executed: """ CREATE ({name: 'a'}), ({name: 'b'}) """ When executing query: """ MATCH (n) RETURN n """ Then the result should be: | n | | ({name: 'a'}) | | ({name: 'b'}) | And no side effects

feature results

slide-7
SLIDE 7

Cucumber tests

Scenario: Find all nodes Given an empty graph And having executed: """ CREATE ({name: 'a'}), ({name: 'b'}) """ When executing query: """ MATCH (n) RETURN n """ Then the result should be: | n | | ({name: 'a'}) | | ({name: 'b'}) | And no side effects

feature results

grammar FeatureResults; value : node | relationship | path | integer ... ; node : nodeDesc ; nodeDesc : '(' (label)* WS? (propertyMap)? ')' ; relationship : relationshipDesc ; relationshipDesc : '[' relationshipType WS? (propertyMap)? ']' ; path : '<' pathBody '>' ; pathBody : nodeDesc (pathLink)* ;

FeatureResults.g4

slide-8
SLIDE 8

Side effects

Scenario: Create a pattern with multiple hops Given an empty graph When executing query: """ CREATE (:A)-[:R]->(:B)-[:R]->(:C) """ Then the result should be empty And the side effects should be: | +nodes | 3 | | +relationships | 2 | | +labels | 3 | When executing control query: """ MATCH (a:A)-[:R]->(b:B)-[:R]->(c:C) RETURN a, b, c """ Then the result should be: | a | b | c | | (:A) | (:B) | (:C) |

slide-9
SLIDE 9

Side effects

Scenario: Create a pattern with multiple hops Given an empty graph When executing query: """ CREATE (:A)-[:R]->(:B)-[:R]->(:C) """ Then the result should be empty And the side effects should be: | +nodes | 3 | | +relationships | 2 | | +labels | 3 | When executing control query: """ MATCH (a:A)-[:R]->(b:B)-[:R]->(c:C) RETURN a, b, c """ Then the result should be: | a | b | c | | (:A) | (:B) | (:C) |

+nodes +relationships +labels +properties

slide-10
SLIDE 10

Exceptions

Background: Given any graph Scenario: Using a non-existent function When executing query: """ MATCH (a) RETURN foo(a) """ Then a SyntaxError should be raised at compile time: UnknownFunction

slide-11
SLIDE 11

Exceptions

Background: Given any graph Scenario: Using a non-existent function When executing query: """ MATCH (a) RETURN foo(a) """ Then a SyntaxError should be raised at compile time: UnknownFunction

~50 features and ~800 scenarios

slide-12
SLIDE 12

TCK for the Neo4j Driver

slide-13
SLIDE 13

Project goal

ingraph TCK test executor

slide-14
SLIDE 14

Project goal

ingraph TCK test executor

slide-15
SLIDE 15

Architecture

Neo4j server test client TCK test executor Neo4j driver restart

slide-16
SLIDE 16

Architecture

Neo4j server test client TCK test executor Neo4j driver restart

slide-17
SLIDE 17

test client

Architecture

Neo4j embedded TCK test executor Neo4j driver

slide-18
SLIDE 18

Converting from Embedded to Driver

slide-19
SLIDE 19

Architecture

FeatureResults grammar (Xtext) Gradle Cucumber Scala Cukes test client Neo4j embedded TCK test executor Neo4j driver Result matchers

slide-20
SLIDE 20

Generated report

Generated Cucumber report

slide-21
SLIDE 21

Points to Discuss

slide-22
SLIDE 22

Side effects

Scenario: Create a pattern with multiple hops Given an empty graph When executing query: """ CREATE (:A)-[:R]->(:B)-[:R]->(:C) """ Then the result should be empty And the side effects should be: | +nodes | 3 | | +relationships | 2 | | +labels | 3 | When executing control query: """ MATCH (a:A)-[:R]->(b:B)-[:R]->(c:C) RETURN a, b, c """ Then the result should be: | a | b | c | | (:A) | (:B) | (:C) |

+nodes +relationships +labels +properties

slide-23
SLIDE 23

Calculating side effects

  • org.neo4j.graphdb.QueryStatistics
slide-24
SLIDE 24

Side effects for properties

Scenario: Non-existent values in a property map are removed with SET = Given any graph And having executed: """ CREATE (:X {foo: 'A', bar: 'B'}) """ When executing query: """ MATCH (n:X {foo: 'A'}) SET n = {foo: 'B', baz: 'C'} RETURN n """ Then the result should be: | n | | (:X {foo: 'B', baz: 'C'}) | And the side effects should be: | +properties | 2 | | -properties | 1 |

:X foo: 'B' baz: 'C' :X foo: 'A' bar: 'B'

  • penCypher/issues/221
slide-25
SLIDE 25

Side effects with Cypher queries

MATCH (n) RETURN n MATCH ()-[r]->() RETURN r ±nodes ±relationships

Idea: an openCypher-compatible engine should support standard Cypher, so use queries to determine side effects

slide-26
SLIDE 26

Side effects with Cypher queries

MATCH (n) UNWIND labels(n) AS label RETURN DISTINCT label ±labels MATCH (n) UNWIND keys(n) AS key RETURN key

  • property

MATCH (n) UNWIND keys(n) AS key WITH properties(n) AS properties RETURN key, properties[key] AS value +property

slide-27
SLIDE 27

Properties considering nodes and relationships

MATCH (n) UNWIND keys(n) AS key RETURN key UNION ALL MATCH ()-[r]->() UNWIND keys(r) AS key RETURN key MATCH (n) UNWIND keys(n) AS key WITH properties(n) AS properties, key RETURN key, properties[key] AS value UNION ALL MATCH ()-[r]->() UNWIND keys(r) AS key WITH properties(r) AS properties, key RETURN key, properties[key] AS value

  • property

+property

𝑙𝑗−1 ∖ 𝑙𝑗 𝑙𝑤𝑗 ∖ 𝑙𝑤𝑗−1

slide-28
SLIDE 28

Unobservable behaviour

CREATE (n) DELETE n RETURN id(n) MATCH (n) SET n.x = 1 WITH n SET n.x = NULL

Created 1 node, deleted 1 node, started streaming 1 record after 17 ms and completed after 18 ms. Set 2 properties, statement completed in 1 ms.

slide-29
SLIDE 29

License considerations

  • Nep4j Embedded: GPLv3
  • Neo4j Driver: ASLv2
  • openCypher: ASLv2
  • ingraph: EPLv1
slide-30
SLIDE 30

License considerations

  • Nep4j Embedded: GPLv3
  • Neo4j Driver: ASLv2
  • openCypher: ASLv2
  • ingraph: EPLv1
slide-31
SLIDE 31

TCK to relational algebra

  • Gábor Szárnyas, József Marton: Formalisation of openCypher

Queries in Relational Algebra (Extended Version)

slide-32
SLIDE 32

TCK to relational algebra

  • Gábor Szárnyas, József Marton: Formalisation of openCypher

Queries in Relational Algebra (Extended Version)

  • nly testing compilation
slide-33
SLIDE 33

Summary

  • Complex toolchain for testing
  • Cucumber & Gradle plug-in
  • Feature parser
  • Test database
  • Points to discuss
  • What is the precise semantics of changes?
  • Check for all behaviour or only observable changes?
  • What license to use?
  • Insert +types?
  • Potential CIRs?
slide-34
SLIDE 34

Related resources

  • Repository:

github.com/bme-db-lab/opencypher-tck-tests

  • Cucumber test reports:

bme-db-lab.github.io/opencypher-tck-tests/feature-overview.html

  • Technical report:

docs.inf.mit.bme.hu/ingraph/pub/opencypher-report.pdf

  • Discussion on observability:

github.com/opencypher/openCypher/issues/221

  • Using ImpermanentGraphDatabase from Gradle:

github.com/neo4j/neo4j/issues/8796

  • GraphAware testing framework:

github.com/graphaware/neo4j-framework/tree/master/tests