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
    • CASE
    • LET Value Expression
    • Value Query Expression
    • List Comprehension
    • 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

Type Conversion Functions

cast()

Converts a value to the specified type.

Syntaxcast(<value> AS <type>)
ArgumentsNameTypeDescription
<value>AnyThe value to convert
<type>/Target type (see supported types below)
Return TypeAs specified by <type>

Supported target types:

CategoryTypes
IntegerINT, INTEGER, INT8, INT16, INT32, INT64, UINT, UINT8, UINT16, UINT32, UINT64
FloatFLOAT, FLOAT32, FLOAT64, DOUBLE, DECIMAL, REAL
StringSTRING, TEXT, VARCHAR
BooleanBOOL, BOOLEAN
TemporalDATE, LOCAL TIME, LOCAL DATETIME, TIMESTAMP, ZONED DATETIME, DURATION
CollectionLIST, RECORD
BinaryBYTES, BINARY
GQL
RETURN cast(1 AS STRING), cast("42" AS INT), cast("true" AS BOOL)

toInteger()

Converts a value to an integer. Returns null if conversion is not possible.

SyntaxtoInteger(<value>)
ArgumentsNameTypeDescription
<value>INT, FLOAT, BOOL, or STRINGThe value to convert
Return TypeINT
GQL
RETURN toInteger("42"), toInteger(3.7), toInteger(true)

Result: 42, 3, 1

toFloat()

Converts a value to a float. Returns null if conversion is not possible.

SyntaxtoFloat(<value>)
ArgumentsNameTypeDescription
<value>FLOAT, INT, BOOL, or STRINGThe value to convert
Return TypeFLOAT
GQL
RETURN toFloat("3.14"), toFloat(42), toFloat(true)

Result: 3.14, 42, 1

toString()

Converts a value to a string. Returns null if conversion is not possible.

SyntaxtoString(<value>)
ArgumentsNameTypeDescription
<value>AnyThe value to convert
Return TypeSTRING
GQL
RETURN toString(42), toString(3.14), toString(true)

Result: "42", "3.14", "true"

toBoolean()

Converts a value to a boolean. Returns null if conversion is not possible. Accepted string values: "true", "t", "yes", "y", "1" for true; "false", "f", "no", "n", "0" for false (case-insensitive).

SyntaxtoBoolean(<value>)
ArgumentsNameTypeDescription
<value>BOOL, INT, FLOAT, or STRINGThe value to convert
Return TypeBOOL
GQL
RETURN toBoolean("true"), toBoolean(1), toBoolean("yes")

Result: true, true, true

toList()

Converts a value to a list. Strings are split into a list of characters. Paths are converted to a list of alternating nodes and edges. Other values are wrapped in a single-element list.

SyntaxtoList(<value>)
ArgumentsNameTypeDescription
<value>AnyThe value to convert
Return TypeLIST
GQL
RETURN toList("hello")

Result: ["h", "e", "l", "l", "o"]

toMap()

Creates a record (map) from key-value pairs.

SyntaxtoMap(<key1>, <value1> [, <key2>, <value2>, ...])
ArgumentsNameTypeDescription
<key>STRINGA key name
<value>AnyThe value for the preceding key
Return TypeRECORD
GQL
RETURN toMap("name", "Alice", "age", 30)

Result: {"name": "Alice", "age": 30}