Skip to main content
A table-valued function (TVF) that reads from a stream: messages from a Kafka topic, or change events from a Postgres table or MongoDB collection. READ_STREAM returns a table with the stream’s declared columns plus source-specific metadata pseudo-columns. A stream tracks a consumed position (Kafka offsets, a Postgres replication-slot position, or a MongoDB resume token). When consume is true (the default), the position advances with the transaction that reads, so each read returns only new data. Position updates commit atomically with the data they produced, which makes ingestion through READ_STREAM exactly-once. For continuous ingestion of Postgres or MongoDB change feeds, prefer a CDC table, which runs this machinery for you; direct READ_STREAM over CDC streams is most useful for inspection and custom pipelines.

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 has the stream’s declared columns plus pseudo-columns that depend on the source. Pseudo-columns are not included in SELECT *; reference them explicitly, double-quoted (for example SELECT "$op", * FROM ...).

Kafka streams

How raw messages map to columns is set by the stream’s TYPE (JSON, CSV, RAW_TEXT, BINARY); see Kafka stream types.

Postgres streams

Private Preview FeatureThis feature is currently in private preview. Contact support@firebolt.io to request early access.
Rows arrive in commit order; uncommitted transactions are never surfaced. See Postgres CDC for delete and key-update row shapes.

MongoDB streams

Private Preview FeatureThis feature is currently in private preview. Contact support@firebolt.io to request early access.
A first consuming read with no stored position starts at the current end of the change feed; it does not replay history.

Examples

Peek at a stream without consuming

Inspect change events on a CDC stream

Ingest Kafka messages into a managed table

The stream’s offsets advance with the insert, so running the statement again returns only messages that arrived after the previous read.

Read a snapshot of a CDC source

Filter and transform while reading

Use Kafka pseudo-columns

Managing consumed positions

Kafka offsets are visible in information_schema.streams and can be repositioned with ALTER STREAM ... SET PARTITION ... OFFSET .... Postgres streams track their position in the source’s replication slot; MongoDB streams store a resume token. Neither is manually repositionable; see the Postgres CDC and MongoDB CDC operations sections.