Skip to content

Schema functions

NebulaGraph supports the following schema functions.

For nGQL statements

Note

  • The following functions are available in YIELD and WHERE clauses.
Function Description
id(vertex) Returns the ID of a vertex. The data type of the result is the same as the vertex ID.
map properties(vertex) Returns the properties of a vertex.
map properties(edge) Returns the properties of an edge.
string type(edge) Returns the edge type of an edge.
src(edge) Returns the source vertex ID of an edge. The data type of the result is the same as the vertex ID.
dst(edge) Returns the destination vertex ID of an edge. The data type of the result is the same as the vertex ID.
int rank(edge) Returns the rank value of an edge.
vertex Returns the information of vertices, including VIDs, tags, properties, and values.
edge Returns the information of edges, including edge types, source vertices, destination vertices, ranks, properties, and values.
vertices Returns the information of vertices in a subgraph. For more information, see GET SUBGRAPH
edges Returns the information of edges in a subgraph. For more information, see GET SUBGRAPH
path Returns the information of a path. For more information, see FIND PATH

Note

Since vertex, edge, vertices, edges, and path are keywords, you need to use AS <alias> to set the alias, such as GO FROM "player100" OVER follow YIELD edge AS e;.

For statements compatible with openCypher

Function Description
id(<vertex>) Returns the ID of a vertex. The data type of the result is the same as the vertex ID.
list tags(<vertex>) Returns the Tag of a vertex, which serves the same purpose as labels().
list labels(<vertex>) Returns the Tag of a vertex, which serves the same purpose as tags(). This function is used for compatibility with openCypher syntax.
map properties(<vertex_or_edge>) Returns the properties of a vertex or an edge.
string type(<edge>) Returns the edge type of an edge.
src(<edge>) Returns the source vertex ID of an edge. The data type of the result is the same as the vertex ID.
dst(<edge>) Returns the destination vertex ID of an edge. The data type of the result is the same as the vertex ID.
vertex startNode(<path>) Visits an edge or a path and returns its source vertex ID.
string endNode(<path>) Visits an edge or a path and returns its destination vertex ID.
int rank(<edge>) Returns the rank value of an edge.

Examples

nebula> GO FROM "player100" OVER follow REVERSELY \
        YIELD src(edge) AS destination;
+-------------+
| destination |
+-------------+
| "player101" |
| "player102" |
...

nebula> LOOKUP ON player WHERE player.age  > 45 YIELD id(vertex);
+-------------+
| id(VERTEX)  |
+-------------+
| "player144" |
| "player140" |
+-------------+

nebula> MATCH (a:player) WHERE id(a) == "player100" \
        RETURN tags(a), labels(a), properties(a);
+------------+------------+-------------------------------+
| tags(a)    | labels(a)  | properties(a)                 |
+------------+------------+-------------------------------+
| ["player"] | ["player"] | {age: 42, name: "Tim Duncan"} |
+------------+------------+-------------------------------+

nebula> MATCH p = (a :player {name : "Tim Duncan"})-[r:serve]-(t) \
        RETURN type(r), rank(r);
+---------+---------+
| type(r) | rank(r) |
+---------+---------+
| "serve" | 0       |
+---------+---------+

nebula> MATCH p = (a :player {name : "Tim Duncan"})-[r:serve]-(t) \
        RETURN startNode(p), endNode(p);
+----------------------------------------------------+----------------------------------+
| startNode(p)                                       | endNode(p)                       |
+----------------------------------------------------+----------------------------------+
| ("player100" :player{age: 42, name: "Tim Duncan"}) | ("team204" :team{name: "Spurs"}) |
+----------------------------------------------------+----------------------------------+

Last update: March 13, 2023
Back to top