Change Password

Input error
Input error
Input error
Submit

Change Nickname

Current Nickname:
Submit
Search
v4.0
    v4.0

    Alias System

    There are two types of aliases, custom alias and system alias.

    Custom Alias

    The target in the previous UQL example is a custom alias. Custom alias is defined by the following rules:

    • Defined by alias keyword as;
    • Please refer to chapter Basic Concepts for the naming conventions of alias
      • Note that custom alias also accepts only 1 character.
      • Cannot have the same name with existing custom alias, nor can system reserved words be used (see chapter Basic Concepts for details).
      • Try to avoid duplicate names with the property names of the nodes or edges to be used in the same statement; if this is not possible, system alias this may be used to disambiguate if necessary.

    When using custom alias, user needs to understand the object that is defined and its life cycle:

    • Object being defined
      • A data column of path, node, edge that is queried, the result after being processed by function or clause (value, array, table). Please see the table below for details.
    • Life cycle
      • In one UQL sentence, alias defined in one chain statement or clause can be used at least in the very next chain statement or clause;
      • In one UQL sentence, alias of the result that is processed by with clause can be used in any chain statement or clause after that with clause.

    There are 6 structure types defined by custom alias:

    Structure Type Definition Example Data Structure Example
    PATH n().e().n() as paths {nodes: [<NODE>, <NODE>, ...], edges: [<EDGE>, <EDGE>, ...]}
    NODE n(as nodes).e().n() {id: , uuid: , schema: , values: {...}}
    EDGE n().e(as edges).n() {uuid: , schema: , from: , from_uuid: , to: , to_uuid: , values: {...}}
    ATTR n(as nodes).e().n()
    with nodes.level as nodeAttr1
    with sum(nodes.level) as nodeAttr2
    Atomic data type without any internal structure, such as string, number and so on
    ARRAY n(as nodes).e().n()
    with collect(nodes.name) as nodeArray
    [<ATTR>, <ATTR>, ...]
    TABLE n(as nodes).e().n()
    with table(nodes.name, nodes.level) as nodeTable
    {headers: [], table_rows: [<ARRAY>, <ARRAY>, ...]}

    When executing a UQL statement, if there is any data stream with no defined alias, or if there is any alias defined but not ever used, the validity and accuracy of UQL might be spoiled. Please avoid missing defining alias or defining not useful alias when writing UQL.

    System Alias

    There are 3 system aliases, prev_n, prev_e and this. They can be used directly without definition:

    • this can be called in all Ultipa filters to represent the current node/edge;
    • prev_n and prev_e are only valid in the basic templates; prev_n refers to the previous node of the current node/edge, prev_e refers to the previous edge of the current node/edge. Please read chapter Template Query for the usage of prev_n and prev_e.

    In practical applications, this is rarely used unless to eliminate any ambiguity; ambiguity occurs when the names of the node/edge's property and the custom alias are repeated, this has to be used in this case if there is a need to refer to the property of node/edge.

    ... as balance
    find().nodes({this.balance > 5000})
    

    Note: In this example, this.balance in nodes() represents the balance property of the current node; since the custom alias defined in the previous statement is still valid in the current statement, using balance in nodes() directly conflicts with the name of node's property balance, so that this is used.

    Please complete the following information to download this book
    *
    公司名称不能为空
    *
    公司邮箱必须填写
    *
    你的名字必须填写
    *
    你的电话必须填写
    *
    你的电话必须填写