Appearance
Types
Every type a column can have, how you write each, and how each compares.
| Type | Holds | Written | Shown as |
|---|---|---|---|
bigint | a whole number of any size | 1000000, 1_000_000, 1e18 | digits |
decimal | an exact number with a fractional part | 1.05, 0.5e3 | plain digits, no exponent |
bool | true or false | true, false | true / false |
string | text | 'Transfer', "it's" | itself |
bytes | any number of bytes | hex longer than 32 bytes, $data | lowercase 0x… |
bytes1 … bytes32 | exactly N bytes | 0xff is bytes1, a 64-digit hex is bytes32 | lowercase 0x… |
address | a chain and 20 bytes | ethereum:0x… | chain:0xChecksummed |
chain | a chain | No literal. $chain, chain(x) | its name, ethereum |
datetime | an instant, to the second, UTC | datetime('2026-09-01') | 2026-09-01T00:00:00Z |
duration | a whole number of seconds | 30s, 15m, 1h, 7d, 2w | 3600s |
T[] | an array of one type | [a, b], r.getStakingModuleIds() | its elements |
| record | named fields | { a: 1, b: 2 } | its fields |
null | no value | null | null |
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
bigintand adecimalcompare as numbers.1 == 1.0istrue. - An
addresscompares with a bare 20-byte literal by its bytes alone, ignoring the chain —t.to == 0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0matches on any chain. In a query that spans two chains, CQL warns (CQL2901). Write the address with its chain to say which chain you meant.address(0)is the same kind of value, the zero address's 20 bytes, sot.from == address(0)finds mints the way the literal would.
bytes4 == bytes32 is a type error, and so is comparing a string with a bigint.
Converting
| From | To | Use |
|---|---|---|
bytesN, string, decimal | bigint | tobigint(x) |
bigint, string | decimal | todecimal(x) |
bigint with a scale | decimal | format(x, decimals) |
decimal with a scale | bigint | parse(d, decimals) |
| anything | string | tostring(x) |
bigint, bytes, address | hex string | tohex(x) |
| a 32-byte word | address, uint8…uint256, int8…int256, bytes1…bytes32, bool, string | x as address |
string or unix seconds | datetime | datetime(x) |
datetime | unix seconds | unixtime(t) |
| seconds | duration | duration(n) |
x as T reinterprets one 32-byte word — a storage slot or a bytes32 — in the layout that Solidity uses. as address takes the low 20 bytes, as uint8 the low byte, and as bytes4 the high four. Read a storage slot uses it.
Arithmetic across types
datetime ± durationis adatetime, and so isduration + datetime.datetime - datetimeis aduration.duration ± duration,duration * bigint,bigint * durationandduration / bigintare durations.duration / bigintkeeps whole seconds and truncates toward zero, asbigint / bigintdoes:1h / 7is514s.bigint ± decimalis adecimal.+does not join strings or bytes. Useconcat.
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 handle it. In where, only true keeps a row. null drops it like false does.