READ_STREAM returns a table with columns defined by the stream’s schema, along with metadata pseudo-columns such as $offset, $partition_id, and $timestamp.
READ_STREAM works with a managed stream object that tracks consumer offsets. When consume is set to true (the default), Firebolt advances the stream’s offsets after reading, so subsequent reads only return new messages.
Prerequisites
Before usingREAD_STREAM, you need:
- A Kafka location that stores connection details for your Kafka cluster:
- A stream object that defines the schema and binds to a Kafka topic:
CREATE STREAM for the full reference.
Syntax
Parameters
Setting
consume to true (the default) makes the query a write operation. Read-only queries, such as standalone SELECT statements outside of CREATE TABLE AS SELECT or INSERT INTO ... SELECT, cannot consume from a stream. Either set consume => false or use READ_STREAM inside a write statement.Return type
The result is a table whose columns match the stream’s schema, plus the following pseudo-columns:
Pseudo-columns are not included in
SELECT * by default — reference them explicitly (for example, SELECT $offset, $partition_id, * FROM ...).
Stream types
TheTYPE parameter on the stream controls how raw Kafka messages are parsed:
Consumer offsets
Firebolt tracks consumer offsets per partition for each stream object. You can inspect offsets throughinformation_schema.streams:
ALTER STREAM:
Examples
Read without consuming
Preview the latest unconsumed messages from a stream without advancing offsets:Ingest into a managed table
Consume messages from the stream and insert them into a Firebolt table in a single statement:Incremental ingestion
Append new messages to an existing table:Filter and transform
Apply SQL transformations on the stream data before loading. For aRAW_TEXT stream, you can parse fields from the raw message: