UltipaDocs
Try Playground
  • Introduction
  • Terminologies
    • Graphset
    • Schema
    • Property
    • Constraints
    • Insert
    • Overwrite or Insert
    • Upsert
    • Update
    • Delete
    • Find Nodes
    • Find Edges
      • AB
      • Autonet
      • Spread
      • Path Template
      • K-Hop
      • K-Hop Template
    • GROUP BY
    • ORDER BY
    • SKIP
    • LIMIT
    • WHERE
    • RETURN
    • WITH
    • UNCOLLECT
    • UNION
    • UNION ALL
    • CALL
    • All Functions
    • Path Functions
    • Aggregate Functions
    • Mathematical Functions
    • Trigonometric Functions
    • String Functions
    • List Functions
    • Datetime Functions
    • Spatial Functions
    • Table Functions
    • Null Functions
    • Type Conversion Functions
  • Operators
  • Expressions
    • Index
    • Full-text Index
    • Vector Index
    • Cache
    • Overview
    • Managing HDC Graphs
    • HDC Graph Queries
    • Process
    • Job
    • Execution Plan
    • Alias
    • Filter
    • Values and Types
    • Data Flow in Queries
    • Comments
    • Reserved Words
  • Access Control
  1. Docs
  2. /
  3. UQL
  4. /
  5. Functions

List Functions

append()

Appends an element to the end of the list and returns the updated list.

Syntaxappend(<list>, <elem>)
ArgumentsNameTypeDescription
<list>LISTThe target list
<elem>AnyThe element to be added
Return TypeLIST
UQL
with ["a", 1, 2] as myList
return append(myList, "b")

Result:

append(myList, "b")
["a",1,2,"b"]

difference()

Returns the difference between two lists, generating a new list of elements found in the first list but not in the second. Duplicates are preserved.

Syntaxdifference(<list_1>, <list_2>)
ArgumentsNameTypeDescription
<list_1>LISTThe first list
<list_2>LISTThe second list
Return TypeLIST
UQL
with [1,2,2,3] as l1, [3,4,5] as l2
return difference(l1, l2)

Result:

difference(l1, l2)
[1,2,2]

head()

Returns the first element in a list.

Syntaxhead(<list>)
ArgumentsNameTypeDescription
<list>LISTThe target list
Return TypeSTRING
UQL
with ["a", 1, 2] as myList
return head(myList)

Result:

head(myList)
a

intersection()

Returns the intersection of two lists, producing a new list of elements common to both. Duplicates are included.

Syntaxintersection(<list_1>, <list_2>)
ArgumentsNameTypeDescription
<list_1>LISTThe first list
<list_2>LISTThe second list
Return TypeLIST
UQL
with [1,2,3,3] as l1, [3,3,4,5] as l2
return intersection(l1, l2)

Result:

intersection(l1, l2)
[3,3]

listContains()

Checks whether a specified element exists in a list, returning 1 for true and 0 for false.

SyntaxlistContains(<list>, <elem>)
ArgumentsNameTypeDescription
<list>LISTThe list to be checked
<elem>AnyThe element to look for in <list>
Return1 or 0
UQL
with ["a", 1, 2] as myList
return listContains(myList, "b")

Result:

listContains(myList, "b")
0

listUnion()

Returns the union of two lists as a new list containing elements from either input. Duplicates are removed.

SyntaxlistUnion(<list_1>, <list_2>)
ArgumentsNameTypeDescription
<list_1>LISTThe first list
<list_2>LISTThe second list
Return TypeLIST
UQL
with [1,2,2,3] as l1, [3,4,5] as l2
return listUnion(l1, l2)

Result:

listUnion(l1, l2)
[1,2,3,4,5]

reduce()

Performs a calculation iteratively using each element in a list. With a specified initial value, the defined calculation takes the first element of the list as input.

Syntaxreduce(<resAlias> = <initVal>, <elemAlias> in <list> | <calcExp>)
ArgumentsNameTypeDescription
<resAlias>/The alias representing the initial, intermediate and final calculation result
<initVal>/The initial value assigned to <resAlias>
<elemAlias>/The alias representing each element in the list
<list>LISTThe target list
<calcExp>/The calculation expression
Return TypeSTRING
UQL
with [1,3,5] as myList
return reduce(_sum = 0, item in myList | _sum + item) AS listSum

Result:

listSum
9

size()

Returns the number of elements in a list.

Syntaxsize(<list>)
ArgumentsNameTypeDescription
<list>LISTThe target list
Return TypeUINT
UQL
with [1, 2, null, 3] as myList
return size(myList)

Result:

size(myList)
4