UltipaDocs
Products
Solutions
Resources
Company
Start Free Trial
UltipaDocs
Start Free Trial
  • Introduction
  • GQL vs Other Languages
    • Overview
    • Node and Edge Patterns
    • Path Patterns
    • Quantified Paths
    • Questioned Paths
    • Shortest Paths
    • Graph Patterns
    • Overview
    • Open Graph
    • Closed Graph
    • Constraints
    • Unique Identifiers
    • INSERT
    • INSERT OVERWRITE
    • SET
    • REMOVE
    • DELETE
    • Query Composition
    • Result Table and Visualization
    • MATCH
    • OPTIONAL MATCH
    • FILTER
    • LET
    • FOR
    • ORDER BY
    • LIMIT
    • SKIP
    • CALL
    • RETURN
    • Composite Query
    • NEXT
    • All Functions
    • Element Functions
    • Path Functions
    • Aggregate Functions
    • Mathematical Functions
    • Trigonometric Functions
    • String Functions
    • List Functions
    • Datetime Functions
    • Spatial Functions
    • Null Functions
    • Utility Functions
    • Type Conversion Functions
    • Table Functions
    • AI & Vector Functions
    • Database Functions
  • Operators
  • Predicates
  • Expressions
    • Index
    • Full-text Index
    • Vector Index
  • Transactions
  • Triggers
  • Query Management
  • Backup and Restore
    • Variables
    • Values and Types
    • Comments
    • Reserved Words
    • Syntactic Notation
  • GQL Conformance
  1. Docs
  2. /
  3. ISO GQL
  4. /
  5. Functions

Utility Functions

Example Graph

GQL
INSERT (p1:Paper {_id:'P1', title:'Efficient Graph Search', score:6, author:'Alex'}),
       (p2:Paper {_id:'P2', title:'Optimizing Queries', score:9, author:'Alex'}),
       (p3:Paper {_id:'P3', title:'Path Patterns', score:7, author:'Zack'}),
       (p1)-[:Cites {weight:2}]->(p2),
       (p2)-[:Cites {weight:1}]->(p3)

cardinality()

Returns the size of a path, list, or record.

Syntaxcardinality(<expr>)
ArgumentsNameTypeDescription
<expr>PATH, LIST, RECORDThe input expression
Return TypeINT
GQL
MATCH p = ()->() LIMIT 1
RETURN cardinality(p)

Result: 3

GQL
LET myList = [1, 2, null, 3]
RETURN cardinality(myList)

Result: 4

GQL
RETURN cardinality({x: 1, y: 3, z: 34})

Result: 3

typeof()

Returns the type name of a value as a string.

Syntaxtypeof(<expr>)
ArgumentsNameTypeDescription
<expr>AnyThe input expression
Return TypeSTRING
GQL
MATCH (n:Paper) LIMIT 1
RETURN typeof(n.author)

Result:

typeof
STRING
GQL
RETURN typeof(42), typeof("hello"), typeof([1,2,3])

Result:

typeoftypeoftypeof
INTEGERSTRINGLIST

all_different()

Returns true if all arguments are different graph elements (compared by _id).

Syntaxall_different(<elem1>, <elem2> [, ...])
ArgumentsNameTypeDescription
<elem>NODE, EDGETwo or more element variable references
Return TypeBOOL
GQL
MATCH (a), (b), (c)
WHERE a._id = "P1" AND b._id = "P2" AND c._id = "P3"
RETURN all_different(a, b, c)

Result: true