Parameters
<schema name>
<schema name>
Name of the schema containing the graph; if no schema is specified, the graph will be
looked for in the user’s default schema
<graph name>
<graph name>
Name of the graph to query
<match expr>
<match expr>
Any supported Cypher Individual labels, property names, and column names can be double-quoted if needed to avoid
conflicts with the Cypher query syntax:
MATCH expression.For example, to query for relationships with the following criteria:- Starting node can be referred to with
jsin the rest of the graph query - Starting node has both
User&Adminlabels - Starting node has property values of
Joe&Smithfor propertiesfirst_name&last_name, respectively - Ending node is one hop away from the starting node
- Ending node has a label of
User
MATCH expression:| Expression | Description | ||||||
|---|---|---|---|---|---|---|---|
() | Node Matcher Matches any node. | ||||||
(<ref>) | Node Reference Matches any node; matched nodes are able to be referenced as <ref> in the rest of the match statement. | ||||||
(:<label>) | Node Label Matcher Matches any node with a label of <label>; any number of labels can be combined to form a composite restriction:
| ||||||
({<name>: <value>}) | Node Property Matcher Matches any node with a property <name> whose value is <value>; any number of properties can be combined to form a composite restriction requiring a node to have all the specified property values; e.g.: Mutually exclusive with the Node WHERE Clause Matcher | ||||||
(WHERE <expression>) | Node WHERE Clause Matcher Matches any node that meets the restrictions of the given <expression>; this is a standard SQL WHERE clause that can reference a node’s ID, properties, or labels, but cannot include sub-query constructs (ANY/ALL/IN/EXISTS); e.g.: Mutually exclusive with the Node Property Matcher | ||||||
[] | Edge Matcher Matches any edge. | ||||||
[<ref>] | Edge Reference Matches any edge; matched edges are able to be referenced as <ref> in the rest of the match statement. | ||||||
[:<label>] | Edge Label Matcher Matches any edge with a label of <label>; any number of labels can be combined to form a composite restriction:
Each relationship can have only 1 label. | ||||||
({<name>: <value>}) | Edge Property Matcher Matches any edge with a property <name> whose value is <value>; any number of properties can be combined to form a composite restriction requiring an edge to have all the specified property values; e.g.: Mutually exclusive with the Edge WHERE Clause Matcher | ||||||
[WHERE <expression>] | Edge WHERE Clause Matcher Matches any edge that meets the restrictions of the given <expression>; this is a standard SQL WHERE clause that can reference an edge’s label, node IDs, or properties, but cannot include sub-query constructs (ANY/ALL/IN/EXISTS); e.g.: Mutually exclusive with the Edge Property Matcher | ||||||
()-[]->() | Path Matcher Matches any node connected via an edge to another node. Relationships must be specified with a directional arrow indicating the direction of the relationship; however, the direction restriction specified will be ignored if the following hint is given with the query: | ||||||
()-[]->{n[,m]}() | Path Repeater Matches any node connected via n number of edges to another node. If the optional m is specified, the number of edges must be between n and m, inclusive. Any restriction on the edge is in effect for all n to m intermediate edges between the start and end nodes. |
<filter list>
<filter list>
Filter expressions to apply to the entire graph query. The expressions can include columns on
which the graph is based, not just names & labels available in the graph itself.
<return list>
<return list>
Expressions referencing graph names, graph labels, or supporting graph table columns to use as
the result set for the graph query. Each expression must include a unique alias.
<ordering list>
<ordering list>
Ordering expression(s) to apply to the result set. Columns referenced do not have to be present
in the
RETURN clause.<num rows>
<num rows>
Maximum number of records to return in the result set.
Examples
For example, to query for managers in department 6 making more than $150,000:Node Query Example
Edge Query Example
Path Query Example
Variable Hop Path Query Example
SQL/PGQ Query as a Subquery Example
Limitations & Suggestions
- Graph must be created via SQL and must not be altered, either via SQL or a native API.
-
Graph must be created with all nodes having:
- the same identifier combination
- a single column identifier
- the same data type
- the same nullability—when creating a graph with constant values, the
REMOVE_NULLABLEfunction can be used to make the valueNOT NULL
-
Graph should be created with Node & edge
INPUT_TABLESas regular tables or materialized views instead of queries or logical views. This will reduce the complexity of query plans involving joins on the graph source data, and improve the performance of SQL/PGQ queries overall. -
Graph should be created with the
add_table_monitoroption if the data in the graph support tables are expected to change, as those changes would otherwise cause the graph and its tables to go out-of-sync, returning wrong results in SQL/PGQ queries. If the data in the support tables will not change, this option can be omitted. - Querying a graph in this manner generally requires that, when the graph being queried was created, no correlated subqueries were used as part of any input table queries. However, a materialized view can be created containing the query, and then the view can be used in place of the query as an input table.