gsql/ openCypher in GSQL
Last Updated: October 20, 2018

Leveraging the popular openCypher query language within TigerGraph's GSQL engine.

openCypher in GSQL

TigerGraph supports openCypher, a declarative query language for property graphs, by embedding it directly within GSQL queries. This allows developers to use familiar MATCH patterns while benefiting from GSQL's performance.

1. Core Supported Clauses

You can use the following openCypher clauses inside GSQL queries:

  • MATCH: Specify patterns to search for.
  • OPTIONAL MATCH: Patterns that may or may not exist (returns null for missing parts).
  • WITH: Pipe results from one pattern to the next.
  • RETURN: Define the final output.
  • WHERE: Filter results based on attributes or relationships.

2. Key Differences: Schema-First vs. Schema-Optional

While standard openCypher is "schema-optional," TigerGraph's implementation is schema-first.

FeatureopenCypher (Neo4j)openCypher in GSQL
AttributesOptional; can vary per node.Required; must follow vertex/edge type.
Missing DataReturns NULL.Ignores the vertex/edge entirely.
PerformanceFlexible but can be slow.Compiled to machine code for speed.

3. Example Usage

You can wrap openCypher logic within a GSQL query block:

gsqlterminal
CREATE QUERY find_friends(STRING person_name) { MATCH (p:Person {name: person_name})-[:FRIEND]-(f:Person) RETURN f.name AS friend_name; }

4. Limitations

  • No Path Variables: Assigning a path to a variable (e.g., p = (a)-[r]->(b)) is generally restricted in older versions.
  • Strict Connectivity: Patterns in a MATCH clause must typically be connected via edges or shared variables.
  • GSQL-Only Operations: Complex accumulators and control flow (loops) still require GSQL syntax outside the MATCH block.

[!TIP] Use MATCH for simple pattern discovery and switch to native GSQL SELECT statements for deep, high-performance graph analytics.