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
| statements | End with ; and may span lines. -- starts a comment to the end of the line. |
| names | Letters, 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'. |
| numbers | Whole numbers only, except min.cleanable.dirty.ratio, which takes a decimal such as 0.5. |
| bytes | Hex, x'00ff': an even number of digits in either case, the x right before the quote. |
| settings | Dotted names and all-in-sync are written without spaces. |
| short forms | topic …;, lease topic …; and transient topic …; without create mean the same. |
Topics
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.
| partitions n | How many parallel logs the topic is split into. More partitions spread the load across brokers. Cannot change later.Default 1 |
| replicas r | How 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 field | The 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 |
| autoincrement | On a uint64, int64 or uint32 key: write a record with key 0 and the broker picks a new id. See below.Default off |
| transient | Kept 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 |
| lease | A topic whose rows are leases with an owner and an expiry. See leases in the API.Default off: a plain topic |
| names | Up to 249 characters of letters, digits, ., _ and -, not starting with __. Two names differing only in case are not allowed. |
field types
| int8 · int16 · int32 · int64 | Signed whole numbers of 1, 2, 4 and 8 bytes. |
| uint8 · uint16 · uint32 · uint64 | Non-negative whole numbers of 1, 2, 4 and 8 bytes. |
| float32 · float64 | Floating point. Not allowed in a key. |
| bool | true 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. |
| string | Text of any length. |
| bytes(N) | Exactly N bytes, never checked: a hash, a UUID. Written x'…'. |
| bytes | Binary data of any length. |
| numbers in statements | Checked 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. |
| output | uint8 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 brokers | int8, 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.policy | delete: 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.ms | Delete records older than this many milliseconds. Changeable.Default -1: keep forever |
| retention.bytes | Delete the oldest data once a partition is bigger than this. Changeable.Default -1: no limit |
| tier | When 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 |
| durability | majority or all-in-sync: wait for every up-to-date copy instead of most. Fixed.Default majority |
| key.index | on 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.reserve | How many ids a partition sets aside at a time. 1 to 1 048 576. Needs autoincrement. Fixed.Default 4096 |
| autoincrement.max | The 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.key | Give 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.bytes | The size of one file of the log; retention removes whole files. Up to 2 080 374 783. Fixed.Default 64 MiB |
| retention.check.ms | How often retention runs. Fixed.Default 300 000 (5 minutes) |
| file.delete.delay.ms | How long a removed file waits before it is deleted from disk. Fixed.Default 60 000 |
| delete.retention.ms | On 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.ratio | Compact 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.ms | Never 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.
| creating | Write a record with key 0; the stored record gets the next id, and your write's answer carries it. |
| which ids | Partition 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. |
| needs | A 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 out | Past autoincrement.max, a create gets AutoIncrementExhausted (58). |
| importing | To 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. |
Change and drop
| set name = value | Changes the settings marked changeable above. The others are fixed at creation. |
| add · drop · rename column | Each change makes a new schema version. Old records keep the version they were written with and stay readable; nothing is rewritten. |
| set compatibility | backward 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 < N | Stop 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 changeable | Whether a topic is transient, its partitions and its fixed settings. alter … transient and set persistence are refused. |
| drop topic | Refused 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 view | Removes 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
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.
| key | Columns 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). |
| select | The columns of each row: * for all, col as other to rename. |
| aggregates | count(*), 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 record | A 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). |
| unique | No two records may give the same view key: the second write is refused. See rules.Default off |
| constraint … check | A 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 |
| transient | Kept in memory only and rebuilt from the topic after a restart.Default off |
| sources | One typed, keyed topic, persisted or transient. A view cannot read another view. |
| or replace | Changes 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 |
| permissions | Creating 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.
| unique | Refuses 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 views | A record must pass every rule on its topic, or it changes nothing. Records in a batch are checked one by one, in order. |
| which rule | A refusal names it: character_name.unique, account_stats.max_characters; KeyExists/KeyNotFound come from key.index. |
| deletes | Never refused: a key can always be removed, even if that leaves a row breaking a rule. |
| already broken | Rows 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 duplicates | On 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. |
| building | On a big topic, new records reach readers only once the view has caught up. Writes are never refused for it. |
| transactions | Checked 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. |
| batches | An atomic batch to a topic with rules is all or nothing. |
| not allowed | Rules 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
| one row | Name every key column with =. Prints the row or (no row). |
| a scan | Name 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. |
| values | Checked 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 keys | A view keyed by one column has no scan; only one-row reads. |
| show topic · show view | The 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 [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 N | The definition as it was then. |
| diff schema NAME version A to B | What changed between two schema versions. |
| diff catalog offset A to B | Every 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.
| WITH PASSWORD | At least 12 characters. |
| ADD · DROP PASSWORD | A 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 PASSWORD | Replaces both. TERMINATE SESSIONS also logs out everyone using the old one. |
| first login | The 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 · ENABLE | Blocks logins and closes the user's sessions, without deleting them. |
| WITH VERIFIER | Creates 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. |
| names | Letters, digits and . _ @ -, up to 128 characters, not starting with __. A namespace user is 'acme/ws1'. |
roles and grants
| READ | Consume a topic, read a view, join a consumer group. |
| WRITE | Produce to a topic; use a transactional id. |
| CREATE · ALTER · DROP | Define, change and remove topics and views. CREATE ON CLUSTER allows creating any. |
| DESCRIBE | See definitions, counters and history. |
| IMPORT | Write rows with their own autoincrement ids, for a back-fill. Revoke it afterwards. |
| ADMIN | On 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.
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.