Reading data via Query data bindings
Written by
Updated at July 1, 2026
Yandex Data Streams data bindings simplify running recurrent queries on stored data by eliminating the need to specify all operation details.
Query example for reading data via bindings:
SELECT
JSON_VALUE(CAST(Data AS Json), "$.action") AS action
FROM bindings.`input_stream`
LIMIT 10;
Note
Data from a streaming source is delivered as an infinite stream. To prevent infinite streaming and get output in the console, the example uses the LIMIT clause that limits the number of result rows.
Setting up a data binding
To read Yandex Data Streams data via bindings, complete the following steps:
- Setting up a data connection.
- In the Type field, select
Data Streams. - In the Connection dropdown, select the connection you created in the first step.
- Specify the data binding name in the Name field.
- Specify the Yandex Data Streams stream name in the Stream field.
- Specify the data compression method in the Compression field.
- Specify the data transfer format in the Format field.
- Specify data columns and their data types in the Columns fields.
- To validate the data, click Preview.
- Click Create to create a data binding.
Data model
Data is transmitted via Yandex Data Streams in binary format and is read via SQL statements.
SELECT
<expression>
FROM
<connection>.<stream_name>
WITH
(
format=raw,
SCHEMA
(
Data String
)
)
WHERE <filter>;
Where:
<connection>: Name of the Data Streams data stream connection created in the previous step.<stream_name>: Data Streams data stream name.
Data reading example
Query example for reading data from Yandex Data Streams and writing the results to Yandex Data Streams:
$data =
SELECT
JSON_VALUE(Data, "$.host") AS host,
JSON_VALUE(Data, "$.count") AS count,
JSON_VALUE(Data, "$.tag") AS tag,
FROM
(
SELECT
CAST(Data AS Json) AS Data
FROM bindings.`binding_name`
)
WHERE
JSON_VALUE(Data, "$.tag") = "my_tag";
SELECT
*
FROM
$data
LIMIT 10;
Where:
| Field | Type | Description |
|---|---|---|
binding_name |
Name of the binding to the source data stream in the SQL query | |
host |
String | Query string parameter |