Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
  • Blog
  • Pricing
  • Documentation
Yandex project
© 2025 Yandex.Cloud LLC
Yandex Query
    • Data formats and compression algorithms
      • Reading data using connections
      • Reading data using bindings
      • Writing data
    • Working with Managed Service for ClickHouse® databases
    • Working with Managed Service for Greenplum® databases
    • Working with Managed Service for MySQL® databases
    • Working with Managed Service for PostgreSQL databases
    • Working with Managed Service for YDB databases
    • Writing metrics to Yandex Monitoring
  • Access management
  • Pricing policy
  • Integration
  • Audit Trails events
  • FAQ

In this article:

  • Setting up a data binding
  • Data model
  • Example of reading data
  1. Data sources and targets
  2. Working with Data Streams
  3. Reading data using bindings

Reading data using Query bindings

Written by
Yandex Cloud
Updated at June 25, 2024
  • Setting up a data binding
  • Data model
  • Example of reading data

When working with Yandex Data Streams, bindings help you run regular queries to stored data with no need to specify all details of operations with this data.

Example of reading data using bindings:

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

Note

Data from a stream source is transferred as an infinite stream. To stop data processing and output the result to the console, the data in the example is limited with the LIMIT operator that sets the number of rows in the result.

Setting up a data binding

To read data from Yandex Data Streams using bindings:

  1. Setting up a data connection.
  2. In the Type field, select Data Streams.
  3. In the drop-down list of the Connection field, select the connection you created in the first step.
  4. Specify a name for the data binding in the Name field.
  5. Specify a name for a Yandex Data Streams stream in the Stream field.
  6. Specify the data compression method in the Compression field.
  7. Specify the format of transferred data in the Format field.
  8. List data columns and their data types in the Columns fields.
  9. To check the data, click Preview.
  10. Click Create to create a binding.

Data model

Data is sent via Yandex Data Streams in binary form. Data is read using 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>: Name of the data stream in Data Streams.

Example of reading data

Sample query 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 binding to source data stream in SQL query
host String Query string parameter

Was the article helpful?

Previous
Reading data using connections
Next
Writing data
Yandex project
© 2025 Yandex.Cloud LLC