Built-in Functions
This reference is designed for both human developers and AI coding agents. Every entry includes complete syntax that can be used directly in queries.
93 built-in functions across 10 categories: Aggregation (14), String (24), Math (17), Type Conversion (5), Graph Introspection (6), Node Metadata (5), Map and List (5), Date/Time (7), Temporal (1), Utility (5), and Predicates (4).
Aggregation (14)#
Aggregation functions operate across rows in a result set. Use with or without GROUP BY (via WITH).
| Function | Syntax | Description | Return Type |
|---|---|---|---|
count | count(expr) | Number of non-null values | Integer |
count(DISTINCT) | count(DISTINCT expr) | Number of distinct non-null values | Integer |
sum | sum(expr) | Sum of numeric values | Float |
avg | avg(expr) | Arithmetic mean | Float |
min | min(expr) | Minimum value | Same as input |
max | max(expr) | Maximum value | Same as input |
collect | collect(expr) | Collect values into a list | List |
percentile | percentile(expr, p) | Percentile value (p between 0.0 and 1.0) | Float |
stdev | stdev(expr) | Sample standard deviation | Float |
variance | variance(expr) | Sample variance | Float |
median | median(expr) | Median (50th percentile) | Float |
covar_pop | covar_pop(a.x, b.y) | Population covariance between two property columns | Float |
covar_samp | covar_samp(a.x, b.y) | Sample covariance between two property columns | Float |
corr | corr(a.x, b.y) | Pearson correlation coefficient between two property columns | Float |
MATCH (n:Person)
RETURN count(n) AS total, avg(n.age) AS avgAge, percentile(n.score, 0.95) AS p95MATCH (n:Person)
WITH n.department AS dept, collect(n.name) AS members, stdev(n.salary) AS salaryStdev
RETURN dept, members, salaryStdevString (24)#
| Function | Syntax | Description | Return Type |
|---|---|---|---|
toLower | toLower(s) | Convert to lowercase | String |
toUpper | toUpper(s) | Convert to uppercase | String |
trim | trim(s) | Strip leading and trailing whitespace | String |
ltrim | ltrim(s) | Strip leading whitespace | String |
rtrim | rtrim(s) | Strip trailing whitespace | String |
substring | substring(s, start, len) | Extract substring from start position | String |
left | left(s, n) | First n characters | String |
right | right(s, n) | Last n characters | String |
head | head(expr) | First element of a list or comma-separated string | Same as element |
tail | tail(expr) | All elements except the first, from a list or comma-separated string | Same as input |
last | last(expr) | Last element of a list or comma-separated string | Same as element |
replace | replace(s, find, rep) | Replace all occurrences of find with rep | String |
split | split(s, delim) | Split string by delimiter into list | List |
reverse | reverse(s) | Reverse a string or comma-separated list | String |
sort | sort(expr) | Alphabetically sort comma-separated string values | String |
repeat | repeat(s, n) | Repeat string n times | String |
lpad | lpad(s, width, char) | Left-pad string to width with char | String |
rpad | rpad(s, width, char) | Right-pad string to width with char | String |
contains | contains(s, sub) | True if string contains substring | Boolean |
startsWith | startsWith(s, prefix) | True if string starts with prefix | Boolean |
endsWith | endsWith(s, suffix) | True if string ends with suffix | Boolean |
indexOf | indexOf(s, sub) | Position of substring, -1 if not found | Integer |
size | size(s) | Length of string or list | Integer |
toString | toString(expr) | Convert any value to string representation | String |
MATCH (n:Person)
RETURN toLower(n.name) AS lower, left(n.name, 3) AS initials, size(n.name) AS lenMATCH (n:Person)
WHERE startsWith(n.email, 'admin')
RETURN n.name, replace(n.email, '@old.com', '@new.com') AS newEmailMATCH (n:Person)
RETURN lpad(toString(n.id), 6, '0') AS paddedId, repeat('*', n.rating) AS starsMath (17)#
| Function | Syntax | Description | Return Type |
|---|---|---|---|
abs | abs(expr) | Absolute value | Float |
round | round(expr) | Round to nearest integer | Float |
ceil | ceil(expr) | Ceiling (round up) | Float |
floor | floor(expr) | Floor (round down) | Float |
sqrt | sqrt(expr) | Square root | Float |
sign | sign(expr) | Signum: -1, 0, or 1 | Float |
exp | exp(expr) | e raised to the power of the value | Float |
log | log(expr) | Natural logarithm (ln) | Float |
log10 | log10(expr) | Base-10 logarithm | Float |
log2 | log2(expr) | Base-2 logarithm | Float |
power | power(base, exp) | Raise base to exponent | Float |
sin | sin(expr) | Sine (radians) | Float |
cos | cos(expr) | Cosine (radians) | Float |
tan | tan(expr) | Tangent (radians) | Float |
atan2 | atan2(y, x) | Arctangent of y/x (radians) | Float |
pi | pi() | Pi constant (3.14159...) | Float |
e | e() | Euler's number (2.71828...) | Float |
MATCH (n:Sensor)
RETURN n.name, abs(n.reading) AS magnitude, round(n.value * 100) / 100 AS roundedMATCH (n:Point)
RETURN atan2(n.y, n.x) AS angle, sqrt(power(n.x, 2) + power(n.y, 2)) AS distanceType Conversion (5)#
| Function | Syntax | Description | Return Type |
|---|---|---|---|
toString | toString(expr) | Convert to string | String |
toInteger | toInteger(expr) | Convert to integer | Integer |
toFloat | toFloat(expr) | Convert to float | Float |
toBoolean | toBoolean(expr) | Convert to boolean | Boolean |
coalesce | coalesce(a, b, ...) | First non-null value | Same as first non-null |
MATCH (n:Person)
RETURN toInteger(n.ageStr) AS age, coalesce(n.nickname, n.name) AS displayNameGraph Introspection (6)#
| Function | Syntax | Description | Return Type |
|---|---|---|---|
id | id(n) | Internal node or relationship ID | Integer |
labels | labels(n) | List of labels on a node | List<String> |
type | type(r) | Relationship type string | String |
degree | degree(n) | Total degree (in + out) | Integer |
inDegree | inDegree(n) | Incoming relationship count | Integer |
outDegree | outDegree(n) | Outgoing relationship count | Integer |
MATCH (n:Person)
RETURN n.name, degree(n) AS connections, inDegree(n) AS followers, outDegree(n) AS following
ORDER BY degree(n) DESCNode Metadata (5)#
ArcFlow world-model metadata functions for provenance and trust scoring.
| Function | Syntax | Description | Return Type |
|---|---|---|---|
confidence | confidence(n) | World-model confidence score (0.0-1.0) | Float |
observationClass | observationClass(n) | Observation class: observed, inferred, or predicted | String |
authorityPlane | authorityPlane(n) | Authority plane: semantic or scene | String |
clockDomain | clockDomain(n) | Temporal clock domain name | String |
observationSource | observationSource(n) | Source identity (sensor, model, user) | String |
MATCH (n:Observation)
WHERE confidence(n) > 0.8 AND observationClass(n) = 'observed'
RETURN n.name, confidence(n) AS conf, authorityPlane(n) AS planeMap and List (5)#
| Function | Syntax | Description | Return Type |
|---|---|---|---|
properties | properties(n) | Full property map as string | String |
keys | keys(n) | List of property key names | List<String> |
range | range(start, end) | Generate integer sequence [start..=end] | List<Integer> |
mapProjection | n {.name, .age} | Return only named properties as a map | Map |
cardinality | cardinality(expr) | Length of a list or string. Synonym of size — interchangeable in queries. | Integer |
MATCH (n:Person)
RETURN keys(n) AS propKeys, properties(n) AS allPropsMATCH (n:Person)
RETURN n {.name, .age} AS profileUNWIND range(1, 10) AS i
RETURN iDate/Time (7)#
The zero-argument forms are non-deterministic (they return the current time). The string-argument forms parse an ISO 8601 input.
| Function | Syntax | Description | Return Type |
|---|---|---|---|
timestamp | timestamp() | Current Unix timestamp in milliseconds | Integer |
date | date() / date("YYYY-MM-DD") | Current date, or parse ISO date string | String |
time | time() / time("HH:MM:SS") | Current zoned time, or parse ISO time string | String |
datetime | datetime() / datetime("YYYY-MM-DDTHH:MM:SSZ") | Current zoned datetime, or parse ISO datetime string | String |
localTime | localTime() / localTime("HH:MM:SS") | Current local time (no timezone), or parse ISO local time string | String |
localDateTime | localDateTime() / localDateTime("YYYY-MM-DDTHH:MM:SS") | Current local datetime (no timezone), or parse ISO local datetime string | String |
duration | duration("PT1H30M") | Parse an ISO 8601 duration string | Duration |
CREATE (e:Event {name: 'deploy', createdAt: timestamp(), date: date()})
RETURN eTemporal (1)#
Read the engine's logical clock from inside a query.
| Function | Syntax | Description | Return Type |
|---|---|---|---|
walSeq | walSeq() | Current mutation sequence (advances on every CREATE/SET/MERGE/DELETE) | Integer |
-- Snapshot the current seq alongside the data being read
MATCH (e:Event)
RETURN e.id, e.kind, walSeq() AS observed_at_seq-- Pair walSeq() with AS OF seq to anchor a follow-up query at the same logical point
WITH walSeq() AS now_seq
MATCH (a:Account {id: $id}) AS OF seq now_seq
RETURN a.balanceThe integer returned is the same sequence space used by AS OF seq N — pass it back through a parameter to query historical state, write it onto an audit record, or compare against g.seq to compute relative offsets.
The function name is case-insensitive: walSeq(), wal_seq(), WAL_SEQ(), and walseq() are all accepted by the parser. Pick whichever fits your team's naming convention — the canonical form in this reference is walSeq() to match the rest of the function table.
Utility (5)#
| Function | Syntax | Description | Return Type |
|---|---|---|---|
randomUUID | randomUUID() | Generate a UUID v4 string | String |
hash | hash(expr) | Deterministic FNV-1a 64-bit hash as hex string | String |
toJson | toJson(n) | Serialize all node properties to JSON string | String |
size | size(expr) | Length of string or list | Integer |
sessionUser | sessionUser() | Identifier of the current session actor (GQL GS09) | String |
CREATE (n:Record {id: randomUUID(), fingerprint: hash(n.data)})
RETURN nMATCH (n:Person)
RETURN toJson(n) AS jsonPredicates (4)#
Predicate expressions used in WHERE clauses and RETURN.
| Predicate | Syntax | Description | Return Type |
|---|---|---|---|
exists | exists(n.prop) | True if property exists | Boolean |
IS NULL | n.prop IS NULL | True if property is null or missing | Boolean |
IS NOT NULL | n.prop IS NOT NULL | True if property exists and is not null | Boolean |
IN | expr IN [list] | True if value is in the list | Boolean |
MATCH (n:Person)
WHERE exists(n.email) AND n.role IN ['admin', 'editor']
RETURN n.nameMATCH (n:Person)
WHERE n.deletedAt IS NULL
RETURN n.namePath Functions (3)#
Functions for operating on path values bound with MATCH p = ....
| Function | Syntax | Description | Return Type |
|---|---|---|---|
nodes | nodes(path) | Ordered list of nodes along the path | List<Node> |
relationships | relationships(path) | Ordered list of relationships along the path | List<Rel> |
length | length(path) | Number of relationships in the path | Integer |
MATCH p = (a:Person {name: 'Alice'})-[*..5]->(b:Person {name: 'Dave'})
RETURN length(p) AS hops, [n IN nodes(p) | n.name] AS namesList Operations#
List subscript and slice#
-- Access by index (0-based)
RETURN n.tags[0] -- first element
RETURN n.tags[$idx] -- dynamic index via parameter
-- Slice
RETURN n.tags[1..3] -- elements at index 1 and 2
RETURN n.tags[..3] -- first 3 elements
RETURN n.tags[-2..] -- last 2 elementsList comprehension#
-- [variable IN list WHERE filter | transform]
MATCH (n:Person)
RETURN [x IN n.scores WHERE x > 80 | x * 1.1] AS bonus_scores
-- filter only
RETURN [x IN n.tags WHERE x <> 'archived'] AS active_tags
-- transform only
RETURN [x IN range(1, 10) | x * x] AS squaresList quantifiers#
WHERE ALL(x IN n.scores WHERE x > 60) -- all elements match
WHERE ANY(x IN n.tags WHERE x = 'urgent') -- at least one matches
WHERE NONE(x IN n.tags WHERE x = 'spam') -- none matchSee Also#
- Aggregations & Window Functions -- GROUP BY, LAG, LEAD, PERCENT_RANK
- Procedures -- CALL db.* and algo.* procedures
- Operators -- comparison and logical operators