[Yandex Cloud documentation](../../index.md) > [Yandex Query](../index.md) > Data sources and sinks > Working with Data Streams > Reading data via bindings

# Reading data via Query data bindings

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:

```sql
SELECT
    JSON_VALUE(CAST(Data AS Json), "$.action") AS action
FROM bindings.`input_stream`
LIMIT 10;
```

{% note info %}

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.

{% endnote %}

## Setting up a data binding

To read Yandex Data Streams data via bindings, complete the following steps:

1. [Setting up a data connection](data-streams.md#create_connection).
1. In the **Type** field, select `Data Streams`.
1. In the **Connection** dropdown, select the connection you created in the first step.
1. Specify the data binding name in the **Name** field.
1. Specify the Yandex Data Streams stream name in the **Stream** field.
1. Specify the [data compression method](formats.md#compression) in the **Compression** field.
1. Specify the [data transfer format](formats.md#formats) in the **Format** field.
1. Specify data columns and their data types in the **Columns** fields.
1. To validate the data, click **Preview**.
1. 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.

```sql
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:

```sql
$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|