A continuous query remains active against an event stream, processing each arriving record and publishing changed results without rerunning the query. In ksqlDB, the stream is backed by a Kafka topic, while the output becomes another topic for downstream consumers. section 8.4.1
Continuous queries support several streaming patterns:
- Filter high-value orders and publish matching events immediately. section 8.4.1
- Maintain grouped counts, updating the result whenever a new order arrives. section 8.4.1
- Restrict aggregations to time windows, such as one-hour tumbling intervals. section 8.4.1
Filtering expensive orders
A query such as CREATE STREAM Expensive_Orders AS SELECT * FROM Orders WHERE amount_paid > 100 EMIT CHANGES continuously emits qualifying orders. Downstream applications subscribe to the output topic instead of repeatedly querying a static result. section 8.4.1
Listing 8.4 Creating a stream of expensive orders with filtering
CREATE STREAM Expensive_Orders AS #1
SELECT *
FROM Orders #2
WHERE amount_paid > 100
EMIT CHANGES; #3
Shows the compact KSQL form for creating a filtered stream with continuously emitted changes. section 8.4.1

