Query Language
Liven uses a pipeline-based query language. Compose stages with | to build complex data flows from simple parts.
How It Works
Every query starts with a from("stream_name") stage that selects a stream. You then chain additional stages with the pipe operator (|) to filter, transform, aggregate, and enrich the data. Terminal dot-methods like .insert() or .listen()execute the query.
from("events") // Select stream| filter(amount > 100) // Filter records| group(status, count()) // Group & aggregate| sort(timestamp, desc) // Sort results| limit(50) // Cap at 50 records
Query Types
There are three classes of operations:
- Read queries — pipeline stages that filter, transform, and analyze existing data. They return matching records.
- Write queries — terminal dot-methods that insert, upsert, update, or delete data. They return a status record.
- Subscriptions — the
.listen()suffix turns any read query into a real-time stream.
Quick Examples
Insert a record
from("users").insert("user_1", {name: "Alice", role: "admin"})
Query with a filter
from("orders") | filter(amount > 100 and status == "completed") | count()
Real-time subscription
from("events") | filter(type == "error") .listen()
Selecting Streams
Choose which stream to query.
Filtering Data
Equality, comparison, string matching, and logical operators.
Inserting & Updating
Insert, upsert, update, and batch operations.
Deleting Data
Delete by key, pipeline delete, empty, and drop.
Real-Time Subscriptions
Live streaming with .listen() and tail().
Aggregations
Count, group, window, sort, limit, and pagination.
Cross-Stream Relationships
Enrich, correlate, sequence, and chain.
Vector Search
Semantic similarity with cosine distance.
Execution Analysis
Understand how queries run with explain().