DRAFTThis page is not published. Only visible in development mode.
RQL pipeline operator

apply

Runs an operator registered by the host application as a pipeline step.

Syntax

$ RQL

apply invokes an operator by name inside a pipeline. The operator is not part of RQL itself: it is code that the embedding application or a plugin registered with the engine under that name. apply is the extension point that lets those operators participate in a pipeline alongside built-ins like map and filter. Referencing a name that was never registered is an error.

The braces after the operator name are required, even when there are no arguments: apply kind_counter without braces is rejected at parse time (error APPLY_002). Inside the braces you pass comma-separated name: value options, for example apply running_sum { value: 10 }. In a view, the options are evaluated once when the view is registered and handed to the operator as its configuration. They are constants, not per-row expressions.

The main home of apply is view definitions. Inside a deferred or transactional view, the flow engine hosts the operator: it receives every change flowing through the pipeline, can keep persistent state between changes, can emit rows with a completely different shape than its input (the operator declares its own output columns), and can run work on a timer. That makes apply the way to add behavior RQL has no keyword for - running tallies, custom alerting, bespoke windowing - while the engine keeps the result incrementally up to date.

When a view is registered, the engine resolves the operator name in order: operators the application registered programmatically first, then native plugin operators, then FFI operators loaded from a configured operator directory. Operators are written in Rust against the operator SDK; the embedded builder registers them by name, and that name is what apply references.

Notes

apply also works in an ad-hoc query, where the operator name resolves against transforms the host registered for the query engine; the transform is invoked on each batch of rows as it streams through the pipeline. Out of the box no transforms are registered, so ad-hoc apply only does something in deployments that ship their own.

The browser sandbox on this page runs the wasm build, which cannot load operator plugins and registers none of its own - so apply cannot execute here. This is the same limitation as window, which only runs where the flow engine is available.

Related