Query Language Syntax Versions
GSQL has two syntax versions: V2 and V1 (legacy version). In TigerGraph 3.5, the default syntax version was changed to V2. This page provides a summary of the differences between V1 and V2, as well as guidance on how to change your V1 query into a V2 query.
Differences between V1 and V2
The two tables below summarize the differences between V1 and V2.
Most of the syntactical differences between V1 and V2 lie in the FROM
clause of the SELECT
statement.
Therefore, Table 1 specifically lays out the differences in the FROM
clause.
Other differences are summarized in Table 2.
Feature | V1 | V2 |
---|---|---|
Step vs path pattern |
The keyword For more information, see |
The keyword |
Edge notation |
Edges in a step can optionally have a right arrowhead outside the parentheses.
For example:
|
No arrowheads are allowed outside the parentheses.
If an edge type is directed, the edge notation must have arrowheads inside the parentheses to indicate direction.
For example:
|
Traversal direction |
The traversal action is from left to right, and the notation uses either a rightward facing arrowhead or no arrowhead to depict a connection. |
The traversal direction is under the control of the query writer, with arrowheads on each edge set to show the direction. |
Source vertex set |
The source vertex set in a step in the |
The source vertex set path pattern in |
Feature | V1 | V2 |
---|---|---|
|
|
|
Not supported. |
Supported. |
|
Data modification statements |
|
|
Changing a query from V1 to V2
This section provides you with instructions to convert a V1 query into a V2 query.
GSQL can detect the syntax version of the query automatically, so there is no need to modify your queries from V1 to V2.
-
Delete, move, or add arrowheads in the
FROM
clause.-
If the edge is undirected, delete the arrowhead outside parentheses in the
FROM
clause.-
For example
Source:s -(Friend:e)→ :t
becomesSource:s -(Friend:e)- :t
-
-
If the edge is directed, move the arrowheads into the parentheses after the edge type. If there is no arrowhead, you must add one after the edge type.
-
For example,
Source:s -(Is_Located_In:e)→ :t
becomesSource:s -(Is_Located_In>:e)- :t
-
This is the most common incompatibility issue between a query written in V1 and V2. Most V1 queries can run smoothly in V2 after the arrowheads are deleted.
-
-
Check for
POST-ACCUM
clauses that aren’t bound to one vertex alias or are bound to more than one vertex alias.-
In V2, every
POST-ACCUM
clause must reference one vertex alias. If your V1 query has aPOST-ACCUM
clause that reference multiple vertex aliases, you need to break thePOST-ACCUM
clause into multiplePOST-ACCUM
clauses, with each clause referencing one vertex alias only.
-
Since a SELECT
statement can only perform one hop in V1, you may have had to write multiple SELECT
statements in order to write a multi-hop query.
With pattern matching in V2, you may choose to rewrite the query to use a single SELECT
statement to perform multiple hops.