OpenCypher Tests¶
The tests validate OpenCypher query support and common graph patterns.
They also include regression coverage for planner behavior that matters to the
Python bindings, such as UNWIND variables being usable inside WHERE
predicates.
OpenCypher¶
OpenCypher is a declarative graph query language for pattern matching and traversal.
import arcadedb_embedded as arcadedb
with arcadedb.create_database("./opencypher_test_db") as db:
db.command("sql", "CREATE VERTEX TYPE Person")
db.command("sql", "CREATE EDGE TYPE Knows UNIDIRECTIONAL")
with db.transaction():
alice = db.new_vertex("Person")
alice.set("name", "Alice").save()
bob = db.new_vertex("Person")
bob.set("name", "Bob").save()
edge = alice.new_edge("Knows", bob)
edge.save()
result = db.query("opencypher", """
MATCH (p:Person)-[:Knows]->(friend:Person)
RETURN friend.name as name
""")
names = [r.get("name") for r in result]
assert "Bob" in names
Running This Test¶
Notable Regression Coverage¶
UNWINDvariables can be referenced fromWHEREclauses duringMATCH- Aggregations on missing labels still return a single row with
0 - Result property order remains stable for projected OpenCypher values
OpenCypher vs SQL MATCH¶
| Feature | SQL MATCH | OpenCypher |
|---|---|---|
| Style | SQL-like | Declarative graph patterns |
| Focus | Set operations + graph patterns | Pattern matching + paths |
| Learning curve | Easier if you know SQL | Easier if you know Cypher |
| Graph traversal | Strong | Strong |
Example Comparison¶
SQL MATCH:
OpenCypher: