Click to copy
Streams • Reviewed for ksqlDB 0.29
How to Insert Query Results into an Existing Stream in ksqlDB
This is an example of inserting a query output into another stream:
INSERT INTO florida_flights
SELECT
flight_id as id,
departed_at as started_at
FROM flights
WHERE from_airport = 'Florida'
EMIT CHANGES;
The selected fields in the query need to be compatible in name and type with the sink stream. In our example, the sink stream florida_flights
was created like this:
CREATE STREAM florida_flights (
id STRING,
started_at TIMESTAMP
) WITH (...)
This type of insert is useful when you need to union two streams into one.
Was this article helpful?