Column Type of Alias
Alias exists to name the data columns generated during or at the end of the execution of UQL, so that the data columns can be called in the subsequent UQL statement.
There are 6 types of data column an alias can represent:
Column Type |
Definition Example | Alias in Example |
Data Structure in RETURN |
---|---|---|---|
NODE | find().nodes() as nodes | nodes | {id: , uuid: , schema: , values: {...}} |
EDGE | find().edges() as edges | edges | {uuid: , schema: , from: , from_uuid: , to: , to_uuid: , values: {...}} |
PATH | n().e().n() as paths | paths | {nodes: [<NODE> , <NODE> , ...], edges: [<EDGE> , <EDGE> , ...]} |
ATTR | ... as nodes with year(nodes.birthday) as attr1, nodes.name as arrt2, nodes.@ as arrt3 |
attr1, attr2, attr3 | Atomic value without internal structure, such as string, number and so on |
ARRAY | ... as paths with pedges(paths) as array |
array | [<ATTR> , <ATTR> , ...] |
TABLE | ... as nodes with table(nodes.name, nodes.birthday) as table |
table | {headers: [...], table_rows: [<ARRAY> , <ARRAY> , ...]} |
Omission of defining alias after a data column is generated, or omission of calling an alias after it is defined, both could induce negative effect on the legality of UQL. Please avoid composing statements that have no alias to define or defining alias that is not called later on.
Custom Alias
A custom alias is defined by developers using keyword as
. The alias defined in the previous table are all custom aliases.
Do not define the same alias for different columns in a UQL statement. Avoid defining alias using the property names of nodes or edges, and system alias this
may be used to disambiguate when necessary.
- 1 ~ 64 characters
- Not allow to start with wave line '~'
- Not allow to contain back quote '`'
- Not allow to use Reserved Words listed in Basic Concepts
A custom alias may represent: NODE, EDGE, PATH, ATTR, ARRAY, TABLE
Life cycle of a customer alias: anywhere after the alias is defined.
System Alias
System alias prev_n
, prev_e
and this
are defined by Ultipa system. They can be used directly without definition:
System Alias | Meaning | Column Type | Life Cycle |
---|---|---|---|
this |
Current node or edge | NODE or EDGE | In any filter |
prev_n |
The previous node of the current node or edge | NODE | In the filter of any basic template |
prev_e |
The previous edge of the current node or edge | EDGE | In the filter of any basic template |
Please read chapter Template for details on prev_n
and prev_e
.
In practical this
is rarely used unless to eliminate any ambiguity; ambiguity occurs when the property names of the node/edge correspond with the custom alias, in which case this
has to be used to refer to the property of node/edge.
... as balance
find().nodes({this.balance > 5000})
Note: this.balance
in nodes()
represents the property balance of the current node; since the custom alias defined in the previous statement is valid in the current statement, using balance
in nodes()
directly conflicts with the name of node's property balance, so that this
is used.
Call an Alias
Suppose that nodes
, edges
, paths
, attr
, array
and table
are aliases of NODE, EDGE, PATH, ATTR, ARRAY and TABLE, below call formats are supported:
The alias of NODE, EDGE and PATH in the RETURN clause carries schema and system properties (
_uuid
,_id
,_from
,_to
,_from_uuid
,_to_uuid
) of nodes and/or edges by default, this information covers the table below.
Call Format | Result |
Specification | Content |
---|---|---|---|
nodes.<property> |
ATTR | Call in any statement | Node property (or null if the node property does not exist) |
nodes.@ |
ATTR | Call in any statement | Node schema |
nodes |
NODE | Call in any statement | Node data structure without any custom properties |
nodes{<property>, ...} |
NODE | Call in RETURN clause | Node data structure with designated custom properties |
nodes{*} |
NODE | Call in RETURN clause | Node data structure with all custom properties |
edges.<property> |
ATTR | Call in any statement | Edge property (or null if the edge property does not exist) |
edges.@ |
ATTR | Call in any statement | Edge schema |
edges |
EDGE | Call in any statement | Edge data structure without any custom properties |
edges{<property>, ...} |
EDGE | Call in RETURN clause | Edge data structure with designated custom properties |
edges{*} |
EDGE | Call in RETURN clause | Edge data structure with all custom properties |
paths |
PATH | Call in any statement | Path data structure without any custom properties of its nodes and edges |
paths{<property>, ...}{<property>, ...} |
PATH | Call in RETURN clause | Path data structure with designated custom properties of its nodes and designated custom properties of its edges |
paths{*}{<property>, ...} |
PATH | Call in RETURN clause | Path data structure with all custom properties of its nodes and designated custom properties of its edges |
paths{<property>, ...}{*} |
PATH | Call in RETURN clause | Path data structure with designated custom properties of its nodes and all custom properties of its edges |
paths{<property>} |
PATH | Call in RETURN clause | Path data structure with designated custom properties of its nodes and edges |
paths{*} |
PATH | Call in RETURN clause | Path data structure with all custom properties of its nodes and edges |
attr |
ATTR | Call in any statement | The atomic value |
array |
ARRAY | Call in any statement | The array |
array[n] |
ATTR | Call in any statement | The element of array with index n |
array[n1:n2] |
ARRAY | Call in any statement | A sub-array formed by element with index n1~n2 |
array[:n] |
ARRAY | Call in any statement | A sub-array formed by element with index 0~n |
array[n:] |
ARRAY | Call in any statement | A sub-array formed by element with index n~<length-1> |
table |
TABLE | Call in RETURN clause | The table |
Read chapter Data Stream | Clause for the detailed description of RETURN.