Skip to content

Functions ​

Every function, by what it works on: 36 that take one row's values and 12 aggregates for summarize.

A function given null returns null, except the four that exist to handle it — isnull, isnotnull, coalesce and iff.

Null ​

FunctionGives
isnull(x), isnotnull(x)whether x is null
coalesce(a, b, …)the first argument that is not null; all must share a type
iff(c, a, b)a when c is true, otherwise b; same as c ? a : b

Numbers ​

FunctionGives
format(x, decimals)x with the point moved left decimals places, exact: format(1e18, 18) is 1.0
parse(d, decimals)the reverse: parse(1.05, 18) is 1050000000000000000; extra digits are dropped
abs(x)the absolute value
pow(base, exp)base to the power exp; exp may not be negative and very large results are refused
tobigint(x)a whole number from bytes, a string or a decimal; null when it cannot
todecimal(x)a decimal from a whole number or a string; null when it cannot

Time ​

FunctionGives
bin(t, d)t rounded down to a multiple of d — the buckets every 1h samples on
blockat(chain, t)the last block at or before t; null before the chain began
datetime(x)a datetime from an ISO-8601 string or unix seconds; null when it cannot parse
unixtime(t)unix seconds
duration(n)a duration of n seconds, the function form of 3600s
totalseconds(d)the seconds in a duration

Text and bytes ​

FunctionGives
tostring(x)any value as text; an address as chain:0x…, a datetime as 2026-09-01T00:00:00Z
tohex(x)a number, bytes or address as 0x…; an address without its chain
concat(a, b, …)strings joined, or bytes joined — not both in one call
len(x)the length of a string in characters, of bytes in bytes, of an array in elements
slice(b, start, len)len bytes of b from start; null when out of range
keccak256(x)the Keccak-256 of bytes or a string, as bytes32
pad32(x)a value left-padded to 32 bytes, the way the ABI encodes a word

Addresses and chains ​

FunctionGives
address(chain, b)an address on chain from 20 bytes
raw(a)the 20 bytes of an address, without its chain
chain(a)the chain of an address; chain(1) and chain('ethereum') name one directly
iscontract(a)whether there is code at a at the row's block

ABI encoding ​

FunctionGives
selector(sig)the 4-byte selector of a function signature
topic0(sig)the 32-byte topic of an event signature
abi_encode(sig, args…)the arguments encoded as bytes, without a selector
abi_decode(sig, data)data decoded by a signature; a record for several outputs, null on a misfit

Calls ​

FunctionGives
revert_reason(call)null when the call succeeded; otherwise its Error(string) text, a Panic code, a decoded custom error, or the raw bytes

Arrays ​

FunctionGives
contains(xs, x)whether x is an element of xs; the same test as x in xs
array_concat(a, b, …)the arrays joined
array_sort(xs)sorted ascending, null first

Storage ​

FunctionGives
slot(mapping: n, key: k)the slot of mapping[k] when the mapping is in slot n
slot(array: n, index: i)the slot of element i of a dynamic array in slot n
slot(base: s, offset: k)slot s + k, for a struct member

These follow Solidity's layout exactly, and a nested mapping passes an inner slot(…) as the mapping: argument. They are the only functions that take named arguments.

Aggregates ​

For summarize. Rows reach an aggregate in pipeline order — chain, block, address, transaction, log — which is what first, last and make_list mean.

FunctionGives
count()the rows in the group
count_distinct(x)the distinct values of x
sum(x), min(x), max(x)exact
avg(x)to 38 significant digits; a rounded average is reported as CQL4901
first(x), last(x)the first and last value in pipeline order
make_list(x)every value, in order
make_set(x)the distinct values; all null values count as one
arg_max(x, cols…), arg_min(x, cols…)the listed columns from the row where x is largest or smallest; * for all of them

See also ​