ADR-0241: A log is filtered and tailed by Rahdar, in the SQL WHERE dialect
- Status: accepted
- Date: 2026-12-03
- Deciders: maintainers
Context
A Kafka broker cannot filter records where they are kept, so the topic browse disabled its filter. The SQL console already reads Kafka topics, evaluates a WHERE clause in Rahdar over what it reads, refuses a predicate on a masked field, and streams tails over SSE with a database-backed ticket. Operators asked to filter the browse and to follow a topic live, without a consumer group. feature.sql depends on feature.messages, so the browse cannot call into SQL.
Decision
- A log's browse and tail accept the SQL console's WHERE dialect, evaluated by Rahdar over the records it reads, with the console's masked-field guard. The dialect gains
key,partitionandoffseton a log. A queue keeps the broker's selector, and the view names which dialect it accepts. - The WHERE-only core (the predicate AST, the condition parser, the evaluator, the masked-field guard) moves into
feature.messages. SQL keeps SELECT, FROM, ORDER BY, the index columns, pushdown and its own tail, and uses the moved core. - A filtered page reads until it has a page of matches or has scanned a cap (default 5,000 records, shared round-robin across partitions), and states what it scanned and where the next page resumes.
- Following a log is a server stream from the log end. The client posts the tail and gets a single-use, owner-bound ticket from a database-backed store that SQL shares (
stream_ticket), then opens the stream with it, so the filter is never in a URL and any replica can serve it. Rahdar polls each partition from its next offset without a group. The tail is complete unless it reports a gap (retention or compaction removed records between reads), and it says when it is behind.
Consequences
- Operators learn one filter language across browse, tail and the SQL console, and a masked field is refused the same way everywhere.
- A rarely matching filter costs up to the scan cap in reads per page; the page says so.
- A busy topic can outrun the tail; the view says it is behind instead of calling itself live.
- The SQL console's ticket table is replaced by the shared one.
Alternatives considered
- A new expression language (CEL, JSONPath). More expressive on nested values, but a second dialect, a new library and a second masking guard.
- A
platform/filtermodule. An extra module and edge for one pair of consumers. - The browser polling the browse endpoint. A request per second per tab, no stream cap, and the filter in the URL.
- Reusing the SQL tail. It would invert the module dependency, and it samples queues where a log tail is complete.