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
SELECT * FROM cypher('graph_name', $$
CREATE (A:Person {name: 'Alice', age: 38, eyes: 'brown'}),(B:Person {name: 'Bob', age: 25, eyes: 'blue'}),
(C:Person {name: 'Charlie', age: 53, eyes: 'green'}),
(D:Person {name: 'Daniel', age: 54, eyes: 'brown'}),
(E:Person {name: 'Eskil', age: 41, eyes: 'blue', array: ['one', 'two', 'three']}),
(A)-[:KNOWS]->(B),
(A)-[:KNOWS]->(C),
(B)-[:KNOWS]->(D),
(C)-[:KNOWS]->(D),
(B)-[:KNOWS]->(E)
$$) as (result agtype);
keys()keys() returns a list of strings containing the property names of a vertex, edge, or map.
Syntax: keys(expression)
Returns:
An agtype list containing string elements.
Parameters:
| Name | Description |
|---|---|
expression |
An expression returning a vertex, edge, or map. |
Notes:
keys(null) returns null.Query:
SELECT * FROM cypher('graph_name', $$
MATCH (a)
WHERE a.name = 'Alice'
RETURN keys(a)
$$) as (result agtype);
Returns a list of all property names on the vertex bound to a.
Result:
| result |
|---|
| ["age", "eyes", "name"] |
| 1 row |
range()range() returns a list of all integer values in the range bounded by the start value start and end value end, where the difference between any two consecutive values — the step — is constant (i.e., an arithmetic sequence). The range is inclusive: the sequence always includes start, and may include end, depending on the values of start, step, and end.
Syntax: range(start, end [, step])
Returns:
An agtype list containing integer elements.
Parameters:
| Name | Description |
|---|---|
start |
An expression returning an integer value. |
end |
An expression returning an integer value. |
step |
A numeric expression defining the constant difference between consecutive values; defaults to 1. |
Query:
SELECT *
FROM cypher('graph_name', $$
RETURN range(0, 10), range(2, 18, 3)
$$) as (no_step agtype, step agtype);
Returns two lists of integers for the specified ranges.
Result:
| no_step | step |
|---|---|
| [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | [2, 5, 8, 11, 14, 17] |
| 1 row |
labels()labels() returns a list of strings containing the labels of a vertex.
Syntax: labels(vertex)
Returns:
An agtype list containing string elements.
Parameters:
| Name | Description |
|---|---|
vertex |
An expression returning a single vertex. |
Notes:
labels(null) returns null.Query:
SELECT *
FROM cypher('graph_name', $$
MATCH (a)
WHERE a.name = 'Alice'
RETURN labels(a)
$$) as (edges agtype);
Returns a list of all labels assigned to the vertex bound to a.
Result:
| edges |
|---|
| ["Person"] |
| 1 row |
nodes()nodes() returns a list of all vertices in a path.
Syntax: nodes(path)
Returns:
An agtype list containing vertex entities.
Parameters:
| Name | Description |
|---|---|
path |
An expression returning an agtype path. |
Notes:
nodes(null) returns null.Query:
SELECT *
FROM cypher('graph_name', $$
MATCH p = (a)-[]->(b)-[]->(c)
WHERE a.name = 'Alice' AND c.name = 'Eskil'
RETURN nodes(p)
$$) as (vertices agtype);
Returns a list of all vertices in path p.
Result:
| vertices |
|---|
| [{"id": 844424930131969, "label": "Person", "properties": {"age": 38, "eyes": "brown", "name": "Alice"}}::vertex, {"id": 844424930131970, "label": "Person", "properties": {"age": 25, "eyes": "blue", "name": "Bob"}}::vertex, {"id": 844424930131973, "label": "Person", "properties": {"age": 41, "eyes": "blue", "name": "Eskil", "array": ["one", "two", "three"]}}::vertex] |
| 1 row |
relationships()relationships() returns a list of all edges in a path.
Syntax: relationships(path)
Returns:
An agtype list containing edge entities.
Parameters:
| Name | Description |
|---|---|
path |
An expression returning an agtype path. |
Notes:
relationships(null) returns null.Query:
SELECT *
FROM cypher('graph_name', $$
MATCH p = (a)-[]->(b)-[]->(c)
WHERE a.name = 'Alice' AND c.name = 'Eskil'
RETURN relationships(p)
$$) as (edges agtype);
Returns a list of all edges in path p.
Result:
| edges |
|---|
| [{"id": 1125899906842640, "label": "KNOWS", "end_id": 844424930131989, "start_id": 844424930131988, "properties": {}}::edge, {"id": 1125899906842644, "label": "KNOWS", "end_id": 844424930131992, "start_id": 844424930131989, "properties": {}}::edge] |
| 1 row |
toBooleanList()toBooleanList() converts a list of values into a list of booleans and returns it. If any input value cannot be converted to a boolean, the corresponding element in the output list is null.
Syntax: toBooleanList(list)
Returns:
An agtype list containing converted elements; each element is either a boolean or `null`, depending on the input value.
Notes:
null.list is null, the function returns null.Query:
SELECT * FROM cypher('graph_name', $$RETURN toBooleanList(["true", "false", "true"])
$$) AS (toBooleanList agtype);
Result:
| toBooleanList |
|---|
| [true, false, true] |
| 1 row |