Skip to content

Types ​

Every type a column can have, how each is written, and how each compares.

TypeHoldsWrittenShown as
biginta whole number of any size1000000, 1_000_000, 1e18digits
decimalan exact number with a fractional part1.05, 0.5e3plain digits, no exponent
booltrue or falsetrue, falsetrue / false
stringtext'Transfer', "it's"itself
bytesany number of byteshex longer than 32 bytes, $datalowercase 0x…
bytes1 … bytes32exactly N bytes0xff is bytes1, a 64-digit hex is bytes32lowercase 0x…
addressa chain and 20 bytesethereum:0x…chain:0xChecksummed
chaina chainno literal; $chain, chain(x)its name, ethereum
datetimean instant, to the second, UTCdatetime('2026-09-01')2026-09-01T00:00:00Z
durationa whole number of seconds30s, 15m, 1h, 7d, 2w3600s
T[]an array of one type[a, b], r.getStakingModuleIds()its elements
recordnamed fields{ a: 1, b: 2 }its fields
nullno valuenullnull

Comparing ​

== and != work between values of the same type. The ordering operators <, <=, > and >= work on numbers, datetimes, durations and bytes of the same width. Two exceptions are worth knowing:

  • A bigint and a decimal compare as numbers; 1 == 1.0 is true.
  • An address compares with a bare 20-byte literal by its bytes alone, ignoring the chain — t.to == 0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0 matches on any chain. In a query that spans two chains CQL warns (CQL2901); write the address with its chain to say which you meant.

bytes4 == bytes32 is a type error, and so is comparing a string with a bigint.

Converting ​

FromToUse
bytesN, string, decimalbiginttobigint(x)
bigint, stringdecimaltodecimal(x)
bigint with a scaledecimalformat(x, decimals)
decimal with a scalebigintparse(d, decimals)
anythingstringtostring(x)
bigint, bytes, addresshex stringtohex(x)
a 32-byte wordaddress, uint8…uint256, int8…int256, bytes1…bytes32, bool, stringx as address
string or unix secondsdatetimedatetime(x)
datetimeunix secondsunixtime(t)
secondsdurationduration(n)

x as T reinterprets one 32-byte word — a storage slot or a bytes32 — the way Solidity lays it out: as address takes the low 20 bytes, as uint8 the low byte, as bytes4 the high four. Read a storage slot uses it.

Arithmetic across types ​

  • datetime ± duration is a datetime; datetime - datetime is a duration.
  • duration ± duration, duration * bigint and duration / bigint are durations.
  • bigint ± decimal is a decimal. + does not join strings or bytes; use concat.

Null ​

Any column can be null: a call the contract reverted, a decode that did not fit, an event argument this interval's ABI lacks. null passes through every operator and function — null + 1 is null — except isnull, isnotnull, coalesce and iff, which exist to deal with it. In where, only true keeps a row; null drops it like false does.

See also ​

  • Numbers — bigint and decimal in practice.
  • Functions — every conversion above.