In developmentArcanum products are not released yet.Get launch updates →
ARCANUM
language

Rune QL

Rune's statement language; for when to use each choice, see Concepts. Create and change topics, build views the broker keeps up to date, read rows by key, look back at any past definition, and manage users and permissions. Type it at the rune console prompt, or run a file with rune ql -f.

Basics

rune> create topic events partitions 3; -- a statement ends with ; rune> CREATE TOPIC Logs; -- keywords in any case; names keep theirs rune> show history since '2026-10-13T00:00:00Z'; -- a string in quotes; times are UTC
statementsEnd with ; and may span lines. -- starts a comment to the end of the line.
namesLetters, digits and _ as they are. Topic and view names are only these. A user, role or namespace name with other characters goes in quotes: 'acme/ws1'.
strings'…', with no escapes. Times are UTC, '2026-10-13T00:00:00Z'.
numbersWhole numbers only, except min.cleanable.dirty.ratio, which takes a decimal such as 0.5.
bytesHex, x'00ff': an even number of digits in either case, the x right before the quote.
settingsDotted names and all-in-sync are written without spaces.
short formstopic …;, lease topic …; and transient topic …; without create mean the same.

Topics

create [transient] [lease] topic NAME [ { field type [autoincrement], … } ] [partitions n] [replicas r] [key field] [with (name = value, …)];

A topic is a log of records split into partitions. Untyped, its records are plain bytes. Typed, it has fields, the broker checks every write against them, and you can give it a key, views and rules.

create topic events; -- untyped, 1 partition, a copy on every broker create topic logs partitions 3 replicas 3; create transient topic presence; -- in memory only, never on disk create topic player { userId uint64, name string(32), score int64 } partitions 4 key userId; create topic character { characterId uint64 autoincrement, userId uint64, name string(16) } partitions 1 replicas 3 key characterId with (cleanup.policy = compact); create lease topic sessions { id uint64, owner string(32) } key id;
partitions nHow many parallel logs the topic is split into. More partitions spread the load across brokers. Cannot change later.Default 1
replicas rHow many brokers keep a copy. At most the number of brokers, and at least the broker's RUNE_MIN_ISR.Default every broker (also 0)
{ field type, … }Makes the topic typed. Every write must match one of the topic's schema versions, its text must be valid UTF-8 and its record key must equal its key field, or the whole batch is refused (SchemaValidationFailed, 24). Typed without a key, it is a checked append-only stream: no views, rules or autoincrement.Default no fields: an untyped topic, its records plain bytes nobody checks
key fieldThe field that identifies a record, like a primary key. Needed for views, rules and autoincrement. An integer, or string(N) with N up to 16; anything else is InvalidSchema (23). With a key, rune schema generate makes C++ types for it.Default none: no key
autoincrementOn a uint64, int64 or uint32 key: write a record with key 0 and the broker picks a new id. See below.Default off
transientKept in memory on its replicas, never written to disk: fast, and gone if every copy restarts. For presence, positions, anything you can lose. Fixed at creation. A view may read it.Default off
leaseA topic whose rows are leases with an owner and an expiry. See leases in the API.Default off: a plain topic
namesUp to 249 characters of letters, digits, ., _ and -, not starting with __. Two names differing only in case are not allowed.

field types

int8 · int16 · int32 · int64Signed whole numbers of 1, 2, 4 and 8 bytes.
uint8 · uint16 · uint32 · uint64Non-negative whole numbers of 1, 2, 4 and 8 bytes.
float32 · float64Floating point. Not allowed in a key.
booltrue or false.
string(N)Text of at most N bytes of UTF-8, stored at a fixed width. Use it for anything you key or index by.
stringText of any length.
bytes(N)Exactly N bytes, never checked: a hash, a UUID. Written x'…'.
bytesBinary data of any length.
numbers in statementsChecked against the column before anything is sent: -129 does not fit int8 column 'a'. A float32 column takes a whole number it can hold exactly, up to 16 777 216.
string(N) · bytes(N)string(N) is stored as N bytes, padded with zeros. bytes(N) takes N from 1 to 65 535.
outputuint8 prints as a number. Floats print in their shortest exact form (0.1, 3.4028235e+38), or inf, -inf, nan, -0. Bytes print as x'…'.
older brokersint8, uint8, int16 and float32 need every broker on feature level 9, bytes(N) level 11; otherwise the statement is refused with InvalidRequest saying so.

settings, with ( name = value, … ) · each once · a value out of range is InvalidRequest (39), e.g. retention.ms -2 < -1

cleanup.policydelete: old data goes by age or size. compact: keeps the newest record of each key forever, like a table. compact_delete: both. Fixed at creation.Default delete
retention.msDelete records older than this many milliseconds. Changeable.Default -1: keep forever
retention.bytesDelete the oldest data once a partition is bigger than this. Changeable.Default -1: no limit
tierWhen a write counts as done: leader as soon as the leader has it (fastest, can be lost in a crash); majority once most copies have it; strict once they have also saved it to disk. Fixed.Default majority
durabilitymajority or all-in-sync: wait for every up-to-date copy instead of most. Fixed.Default majority
key.indexon lets the broker refuse an insert of a key that exists (KeyExists, 56) and an update of one that does not (KeyNotFound, 57). Always on with autoincrement. Fixed.Default off
autoincrement.reserveHow many ids a partition sets aside at a time. 1 to 1 048 576. Needs autoincrement. Fixed.Default 4096
autoincrement.maxThe highest id; past it a create gets AutoIncrementExhausted (58). Maximum 253 − 1 (232 − 1 for uint32); at least 2 × partitions − 1. Needs autoincrement. Fixed.Default 253 − 1 (232 − 1 for uint32), the maximum
copartition.group · partition.keyGive topics the same group so records with the same key land on the same partition number in each, and name the field that chooses the partition. Both are quoted strings: copartition.group = 'g1'. Fixed.Default unset
segment.bytesThe size of one file of the log; retention removes whole files. Up to 2 080 374 783. Fixed.Default 64 MiB
retention.check.msHow often retention runs. Fixed.Default 300 000 (5 minutes)
file.delete.delay.msHow long a removed file waits before it is deleted from disk. Fixed.Default 60 000
delete.retention.msOn a compacted topic, how long a deleted key stays visible as deleted, so slow readers see the delete. Changeable.Default 86 400 000 (one day)
min.cleanable.dirty.ratioCompact once this share of the log is outdated records. 0 to 1, at most 6 decimal places. Changeable.Default 0.5
min.compaction.lag.ms · max.compaction.lag.msNever compact a record younger than the minimum; always compact one older than the maximum. Changeable.Default 0 (minimum), -1 = no maximum (maximum)

Autoincrement

The broker hands out ids, so two servers creating characters at once never pick the same one.

creatingWrite a record with key 0; the stored record gets the next id, and your write's answer carries it.
which idsPartition p of P hands out p + P, p + 2P, p + 3P, …, so each partition's ids are its own. Never reused; gaps after a refused write, an aborted transaction or a failover. rune stats shows the counter and the ids skipped.
needsA new, persisted topic with cleanup.policy = compact and no retention. Turns on key.index. The key field (its name and type) and the partition count can never change.
running outPast autoincrement.max, a create gets AutoIncrementExhausted (58).
importingTo copy rows in with their old ids, write them with the key set. That needs the IMPORT grant, a key that belongs to its partition and is at most the maximum; the counter moves past it. Without IMPORT a write with a key set is refused.
grant import on topic 'user' to user backfill; -- revoke it when the back-fill is done

Change and drop

alter topic events set retention.ms = 604800000, retention.bytes = 1073741824; alter topic player add column guildId int64, set compatibility backward; alter topic player rename column score to points; alter topic player drop column guildId; alter topic player retire version < 3; drop topic events; drop view account_stats;
set name = valueChanges the settings marked changeable above. The others are fixed at creation.
add · drop · rename columnEach change makes a new schema version. Old records keep the version they were written with and stay readable; nothing is rewritten.
set compatibilitybackward or forward: which changes are allowed so readers and writers on different versions keep working. Under forward, dropping a column is refused (SchemaIncompatible, 30).
retire version < NStop accepting writes made with schema versions below N, so old servers cannot keep writing the old shape (SchemaVersionRetired, 67). Records already stored stay readable by readers, views and replays. On its own in the statement; N is from 2 to 65 535, above the last retired version and at most the current one. Typed topics only.
not changeableWhether a topic is transient, its partitions and its fixed settings. alter … transient and set persistence are refused.
drop topicRefused while a view reads the topic (the error names the view), and on a view ("is a view; use DROP VIEW"). An unknown name is UnknownTopic (7). The name can be used again.
drop viewRemoves the view and its rules. Between a drop view and a new create view, writes are not checked: use create or replace to change rules.

Two people changing one topic at once: pass --expected-version to rune ql or console, and a change made against an old version is refused with SchemaConflict (31).

Views

create [or replace] [transient] [unique] view NAME key column | key (column | lower(column) as name, …) [prefix index (column, …)]… as select * | column [as name], … | agg(column | *) as name, … from TOPIC [constraint NAME check (condition)]…;

A view is a table the broker keeps up to date from a typed, keyed topic, read by its key. Write characters to a topic; read "the characters of user 42" or "how many characters user 42 has" from views.

create view character_by_id key characterId as select userId, name, gender from character; create view account_characters key (userId, characterId) as select name, gender from character; create view account_stats key userId as select count(*) as characters from character; create view device_history key (userId, deviceFp) as select min(ts) as firstSeen, max(ts) as lastSeen, count(*) as logins, last(platform) as platform from device_login; create unique view character_name key lower(name) as nameKey as select characterId from character; create view by_ns key (nsId, kind, id) prefix index (nsId) as select data from t; create or replace view account_stats key userId as select count(*) as characters from character constraint max_characters check (characters <= 12);
keyColumns of the topic after from; a view reads one topic, so there is no join. Key columns need not be in the select; they are in every row. What you look rows up by: one column, or several in brackets. Integers, enums, bool and string(N); not floats, and no column twice. lower(name) as nameKey keys a string(N) by its lowercased text (Unicode, no locale), for case-insensitive lookups. At most 128 bytes in all: an integer counts its width, string(N) N, lower(string(N)) 1.5 × N (lowercasing can grow text).
selectThe columns of each row: * for all, col as other to rename.
aggregatescount(*), sum, avg, min, max and last, each with an as name. The key is the group; there is no group by. The source must have one partition and an integer key of at most 8 bytes. A view counts the newest record of each source key, so to count events give each event its own key (as device_login does with an autoincrement id).
one row per recordA view without aggregates must include the source's key in its own key, or be unique; otherwise two records could fight over one row (ViewKeyExpressionInvalid, 59).
uniqueNo two records may give the same view key: the second write is refused. See rules.Default off
constraint … checkA rule on each row; a write that would break it is refused. See rules.
prefix index (a, b)Makes scans by the leading key columns a, b fast. A scan by all key columns but the last is always fast without it. Must be a leading run of the key.Default none
transientKept in memory only and rebuilt from the topic after a restart.Default off
sourcesOne typed, keyed topic, persisted or transient. A view cannot read another view.
or replaceChanges a view that exists, with no gap: the old one keeps serving until the new one has caught up. Without it, an existing name is ViewExists (32).Default off
permissionsCreating a view needs READ on its topic. After that, READ on the view decides who can read it.

Rules

A unique view and a check constraint make the broker refuse a write that breaks them. A refused record is never seen by any view or reader. A writer that asks for the view acknowledgment (checked writes) learns why.

create unique view character_name key lower(name) as nameKey as select characterId from character; -- names unique, any case create view account_stats key userId as select count(*) as characters from character constraint max_characters check (characters <= 12); -- at most 12 per account
uniqueRefuses a record whose view key is already owned by a different record. Keyed by lower(name), "Ada" and "ada" clash.Default off
check (…)Checked on every row the record would produce, in plain or aggregate views; a record is refused only if it changes a column the rule reads. Rule names are unique within the view; at most 64 parts per condition. Compares the view's own columns with constants: = <> < <= > >=, joined by and, or, not and brackets. Columns of at most 16 bytes. A missing (NULL) value passes.
several viewsA record must pass every rule on its topic, or it changes nothing. Records in a batch are checked one by one, in order.
which ruleA refusal names it: character_name.unique, account_stats.max_characters; KeyExists/KeyNotFound come from key.index.
deletesNever refused: a key can always be removed, even if that leaves a row breaking a rule.
already brokenRows that broke a rule before it existed are not repaired. They can shrink, never grow: a 13th character is refused, deleting one is fine, renaming one is fine.
existing duplicatesOn a new unique view, the record with the smallest key owns the name; the others are counted in rune stats as uniqueConflicts. When the owner goes, the next smallest takes over. Clean duplicates up before a back-fill.
buildingOn a big topic, new records reach readers only once the view has caught up. Writes are never refused for it.
transactionsChecked as a whole at commit, on every partition it wrote: one record breaking a rule aborts all of it, naming that record. More than 4 096 records on one partition (RUNE_TXN_JUDGED_RECORDS_MAX) is TxnTooLarge (62). Another write to the same key before the commit is TxnConflict (63); retry it. Rows a transaction wrote are locked until it ends.
batchesAn atomic batch to a topic with rules is all or nothing.
not allowedRules on a transient topic ("constraints need a persisted topic"), on a topic created without write checks (copy it to a new typed topic), more than 32 rule-carrying views on one topic (key.index counts as one).

Reads

rune> select name, gender from account_characters where userId = 42; name gender Ada 1 Brin 0 (2 rows) rune> select * from account_characters where userId = 42 and characterId = 7; rune> select * from account_characters where userId = 42 limit 50; rune> select * from character_name where nameKey = lower('Ada Lovelace'); rune> show topic character; rune> show view account_stats;
one rowName every key column with =. Prints the row or (no row).
a scanName every key column but the last: all rows under that prefix. limit n caps it. Any other where is refused before it is sent; there is no search by other columns.
valuesChecked against the column: '…' is 20 bytes; column 'name' is string(16). A bytes(N) key takes x'…' of exactly N bytes.
lower('…')Lowercases the text the same way the view's lower() key does.
one-column keysA view keyed by one column has no scan; only one-row reads.
show topic · show viewThe full definition (partitions, copies, key, settings, schema; for a view its source, key, columns, rules), then each partition's counters (the same as rune stats). Needs DESCRIBE on the cluster.

A read needs READ on the view; through rune ql, DESCRIBE on the cluster too. Rows of a scan come in storage order, not key order. A scan the view changes under stops with "run it again".

History

Every definition ever made is kept. Look back at any of them; needs DESCRIBE on the cluster.

show history; -- every change, oldest first show history topic events since '2026-10-13T00:00:00Z'; show topic events as of version 2; show view account_stats as of time '2026-10-13T00:00:00Z'; show schema player as of offset 12; diff schema player version 1 to 2; diff catalog offset 3 to 9;
show history [topic | view | schema NAME] [since 'time']Every change, or one object's, optionally from a time on.
show topic | view | schema NAME as of version N | time '…' | offset NThe definition as it was then.
diff schema NAME version A to BWhat changed between two schema versions.
diff catalog offset A to BEvery change between two points of the history. rune catalog exports and compares whole histories.

version counts one object's changes: a topic or view is 1 when created, and each change adds 1; for a schema it is the schema version. offset is a change's place in the whole cluster's history, shared by every object: the first column of show history. time is UTC.

Each history line is one change: its position (offset), the time (UTC), what kind of change, the object and its id, the version before and after, who made it, where it was copied from (after a rune catalog replay, else -) and the statement that did it. A diff line is + topic NAME (added), - view NAME (removed) or ~ topic NAME: field, field (changed, naming what). The client checks each entry's fingerprint as it reads, so a tampered history shows.

Users and permissions

Nothing is allowed until it is granted. These need ADMIN on the cluster, except changing your own password. A statement with a password must come from a file (rune ql -f) or the console, never -e, and only a hash of the password is sent and logged.

CREATE USER ws1 WITH PASSWORD 'correct horse battery'; ALTER USER ws1 ADD PASSWORD 'a second password 1234'; ALTER USER ws1 DROP PASSWORD 1; ALTER USER ws1 SET PASSWORD 'a brand new password 99' TERMINATE SESSIONS; ALTER USER ws1 DISABLE; ALTER USER ws1 ENABLE; DROP USER ws1;
WITH PASSWORDAt least 12 characters.
ADD · DROP PASSWORDA user can have two passwords at once, so you can roll a new one out to servers before removing the old one (DROP PASSWORD 1 or 2).
SET PASSWORDReplaces both. TERMINATE SESSIONS also logs out everyone using the old one.
first loginThe first admin, made by rune security bootstrap, gets a one-time password and can only run ALTER USER me SET PASSWORD until they change it. A user made with CREATE USER logs in with their password as is.
DISABLE · ENABLEBlocks logins and closes the user's sessions, without deleting them.
WITH VERIFIERCreates a user, or sets a password, from a hash made elsewhere (SCRAM-SHA-512$…), so whoever runs the statement never sees the password. Form: SCRAM-SHA-512$<iterations>:<salt>$<stored-key>:<server-key>, standard padded base64, no spaces or line breaks; 4 096 to 100 000 iterations, a 16–64 byte salt, 64-byte keys. Checked before sending; an error names the bad part, never the text. As secret as a password: from a file only. ADD VERIFIER and SET VERIFIER … TERMINATE SESSIONS work like the password forms; setting your own means logging in again.
namesLetters, digits and . _ @ -, up to 128 characters, not starting with __. A namespace user is 'acme/ws1'.

roles and grants

CREATE ROLE world_server; GRANT READ ON TOPIC player_events TO ROLE world_server; GRANT WRITE ON TOPIC PREFIX 'world_' TO ROLE world_server; -- every topic starting world_ GRANT READ ON GROUP PREFIX 'world-' TO ROLE world_server; GRANT WRITE ON TRANSACTIONAL_ID 'ws-1' TO USER ws1; GRANT CREATE ON CLUSTER TO USER ops; GRANT ROLE world_server TO USER ws1; GRANT ADMIN ON NAMESPACE acme TO USER 'acme/admin'; REVOKE WRITE ON TOPIC PREFIX 'world_' FROM ROLE world_server; REVOKE ROLE world_server FROM USER ws1; DROP ROLE world_server; SHOW USERS; SHOW ROLES; SHOW GRANTS FOR USER ws1; SHOW GRANTS FOR ROLE world_server AS OF TIME '2026-10-13T00:00:00Z'; SHOW SECURITY HISTORY USER ws1 SINCE '2026-10-13T00:00:00Z';
READConsume a topic, read a view, join a consumer group.
WRITEProduce to a topic; use a transactional id.
CREATE · ALTER · DROPDefine, change and remove topics and views. CREATE ON CLUSTER allows creating any.
DESCRIBESee definitions, counters and history.
IMPORTWrite rows with their own autoincrement ids, for a back-fill. Revoke it afterwards.
ADMINOn the cluster: users, grants and namespaces. On a namespace: the same, inside it.

Which go with what: a TOPIC takes READ WRITE CREATE ALTER DROP DESCRIBE IMPORT; a VIEW READ CREATE ALTER DROP DESCRIBE; a GROUP READ DESCRIBE; a TRANSACTIONAL_ID WRITE DESCRIBE; the CLUSTER CREATE ALTER DROP DESCRIBE ADMIN. PREFIX 'x' covers every name starting with x. Every change is kept, so AS OF shows who could do what at any past moment.

A whole schema

Accounts, logins and characters for a game: unique sign-in identities, a login history per device, case-insensitive unique character names, at most 12 characters per account.

create topic user { userId uint64 autoincrement, provider uint16, subject string(64), createdAt int64 } partitions 1 replicas 3 key userId with (cleanup.policy = compact); create unique view user_identity key (provider, subject) as select userId from user; create topic device_login { loginId uint64 autoincrement, userId uint64, deviceFp string(64), platform uint16, ts int64 } partitions 1 replicas 3 key loginId with (cleanup.policy = compact); create view device_history key (userId, deviceFp) as select min(ts) as firstSeen, max(ts) as lastSeen, count(*) as logins, last(platform) as platform from device_login; create topic character { characterId uint64 autoincrement, userId uint64, name string(16), gender uint16, createdAt int64 } partitions 1 replicas 3 key characterId with (cleanup.policy = compact); create unique view character_name key lower(name) as nameKey as select characterId from character; create view account_stats key userId as select count(*) as characters from character constraint max_characters check (characters <= 12);

When a statement is refused

TopicExists (25) · ViewExists (32)The name is taken. Use create or replace view, or a --request-id to re-run a script safely.
UnknownTopic (7)No such topic or view.
InvalidSchema (23)A field list or key the broker cannot use, such as a float key.
SchemaIncompatible (30) · SchemaConflict (31)The change breaks the topic's compatibility mode; or someone changed the topic first.
InvalidRequest (39)A setting out of range (the message says which), or a feature the brokers are too old for.
ViewFieldUnresolved (34)A non-key column in an aggregate view is not an aggregate. A column the topic does not have is refused by rune ql itself, with no code.
ViewKeyInvalid (35)The topic has no key, or a prefix index is the whole key, all but its last column (always fast already) or declared twice.
ViewNotCoPartitioned (36)An aggregate, or a view keyed by something other than the topic's key, over more than one partition.
ViewKeyExpressionInvalid (59)A key column of the wrong type, a key over 128 bytes, or a view that does not keep one row per record.
ViewConstraintInvalid (60) · ViewUniqueInvalid (61)A repeated rule name; unique on an aggregate. A check on an unknown column, or with a constant that does not fit the column, is refused by rune ql itself, with no code.
NotAuthorized (45)Missing a grant; see permissions.

All error codes are listed in the API.