YMatrix
Quick Start
Connecting
Benchmarks
Deployment
Data Usage
Manage Clusters
Upgrade
Global Maintenance
Expansion
Monitoring
Security
Best Practice
Technical Principles
Data Type
Storage Engine
Execution Engine
Streaming Engine(Domino)
MARS3 Index
Extension
Advanced Features
Advanced Query
Federal Query
Grafana
Backup and Restore
Disaster Recovery
Graph Database
Introduction
Clauses
Functions
Advanced
Guide
Performance Tuning
Troubleshooting
Tools
Configuration Parameters
SQL Reference
Cypher queries are executed via the cypher function in the ag_catalog schema, which returns a SETOF records.
cypher()The cypher() function executes a Cypher query passed as an argument.
Syntax: cypher(graph_name, query_string, parameters)
Returns:
A SETOF records
Parameters:
| Name | Description |
|---|---|
graph_name |
The target graph for the Cypher query. |
query_string |
The Cypher query to execute. |
parameters |
Optional parameter map for prepared statements; defaults to NULL. |
Note!
- Even if the Cypher query produces no results, a record definition must still be provided.
- The
parametersmap is valid only with prepared statements; using it otherwise raises an error.
Example query:
SELECT * FROM cypher('graph_name', $$
/* Cypher query goes here */
$$) AS (result1 agtype, result2 agtype);
Cypher cannot be used directly inside SQL expressions. Instead, use a subquery. For details on embedding Cypher queries in expressions, see [Advanced Usage]().
SELECT ClauseCalling cypher() as a standalone column in the SELECT clause is not allowed. However, cypher() may be used within conditional clauses (e.g., WHERE, HAVING).
Unsupported usage:
SELECT
cypher('graph_name', $$
MATCH (v:Person)
RETURN v.name
$$);
Error message:
ERROR: cypher(...) in expressions is not supported
LINE 3: cypher('graph_name', $$
^
HINT: Use subquery instead if possible.