Migrating from Yandex Query
Warning
Starting October 13, 2026, Yandex Query will be unavailable to new users.
Current users will be able to create and modify entities until November 10, 2026. Afterwards, the service will go read-only and cease to operate on December 14, 2026. For more information on the timing and procedure, see Yandex Query shutdown.
After closing Yandex Query, you can work with the data in one of the following ways:
- Direct reading from Object Storage. Read data from the bucket using S3-compatible utilities, libraries, or your application.
- Yandex Managed Service for YDB. Run federated queries against files in Object Storage using external data sources and external tables. You can write the results to the output bucket.
Warning
Connections, data bindings, and Yandex Query queries are not automatically migrated. Recreate them by following the steps below. Closing Yandex Query does not affect the data in the Object Storage buckets.
This guide describes the migration of analytical queries. There is no direct equivalent in Yandex Cloud for the streaming requests of Yandex Query.
How to choose your target solution
This section provides a brief comparison of methods for handling data after closing Yandex Query.
|
Scenario |
How do you use Yandex Query |
|
You read files, such as usage details in CSV format, and process them within the application. |
|
|
You regularly run analytical queries against files in a bucket, store query text in your code, or use data bindings. |
|
|
You are building frequently updated dashboards or repeatedly reading the same data. |
Choose direct reading from Object Storage if:
- Data processing is already implemented in your application.
- Queries are simple and do not require SQL.
- You read files irregularly or only once.
Choose federated queries in Yandex Managed Service for YDB if:
- Data must remain in the bucket.
- You want to retain SQL queries and the familiar model of working with external data.
- Same files are not read repeatedly.
Choose column-oriented tables in Yandex Managed Service for YDB if:
- Same data is used in recurring queries or dashboards.
- Speed of repetitive analytical queries is important.
- You are ready to load data from the bucket into the database.
Tip
If you used Yandex Query for SQL queries against files in Object Storage, start with federated queries in Yandex Managed Service for YDB. This option requires fewer changes to queries and does not require moving the source data out of the bucket.
Payment models vary. In Yandex Query, you pay for the amount of data read by queries. When reading directly from Object Storage, operations and outbound traffic are charged. In Yandex Managed Service for YDB, dedicated computing resources and database storage are charged independently of the number of requests. For more details on resource costs, see Object Storage pricing policy and Yandex Managed Service for YDB pricing policy.
Direct reading from Object Storage
This scenario is suitable if you perform all the necessary data processing on your end.
Getting started
-
Create a service account to perform the read operation.
-
Assign the
storage.viewerrole to the service account for the bucket or the folder containing it. -
Create a static access key for the service account.
Save the
key_idandsecretvalues: the secret key will not be shown again.
Read the data
-
Configure the AWS CLI with the service account key.
-
View the list of files:
aws --endpoint-url=https://storage.yandexcloud.net \ s3 ls s3://<bucket_name>/<prefix>/ -
Download the files:
aws --endpoint-url=https://storage.yandexcloud.net \ s3 cp s3://<bucket_name>/<prefix>/ ./data/ --recursive
This example reads CSV files with a specified prefix and calculates the sum for a column, just as the SELECT service_name, SUM(cost) ... GROUP BY service_name query would in Yandex Query. Check the column names against the headers of your files.
import boto3
import pandas as pd
s3 = boto3.client(
"s3",
endpoint_url="https://storage.yandexcloud.net",
aws_access_key_id="<key_ID>",
aws_secret_access_key="<secret_key>",
)
frames = []
paginator = s3.get_paginator("list_objects_v2")
for page in paginator.paginate(Bucket="<bucket_name>", Prefix="<prefix>/"):
for obj in page.get("Contents", []):
if obj["Key"].endswith(".csv"):
body = s3.get_object(Bucket="<bucket_name>", Key=obj["Key"])["Body"]
frames.append(pd.read_csv(body))
df = pd.concat(frames)
print(df.groupby("service_name")["cost"].sum().sort_values(ascending=False))
Yandex Managed Service for YDB
Entity mapping
|
Yandex Query |
Yandex Managed Service for YDB |
|
Connections to Object Storage |
|
|
Data binding |
|
|
Accessing a binding: |
Accessing an external table by name: |
|
Authentication via service account |
Static access key of the service account stored in the database secrets |
|
Reading files by mask, partitioning, |
Supported with the same syntax |
|
Formats: |
Supported |
|
Writing the result to a bucket: |
Supported with the same syntax |
|
Connections with Managed Service for PostgreSQL, Managed Service for ClickHouse®, Managed Service for MySQL®, and Yandex MPP Analytics for PostgreSQL |
Federated queries |
|
Streaming queries to Yandex Data Streams |
No analog |
|
Connections to Monitoring |
No analog |
|
Saved queries |
Store query texts in your repository |
Getting started
-
Create a Yandex Managed Service for YDB database with dedicated resources in the same cloud where the data buckets are located.
Note
External data sources are available only in databases with dedicated resources. In the database in serverless mode, a query to an external source will fail with the
External data sources are disablederror. -
Assign the
ydb.editorrole for the database to the user who will be migrating the queries. -
Create a service account and static access key, as described in the Direct reading from Object Storage section. If requests write results to a bucket, additionally assign the
storage.uploaderrole to the service account. -
Save the query texts, connection parameters and binding settings from Yandex Query: names, bucket paths, format, compression, schema, and partitioning settings.
Federated queries: reading files from Object Storage
This scenario mirrors the operation of Yandex Query: the data remains in the bucket, and the database reads it with every query.
Create an external data source
-
Store the static key in the database secrets:
CREATE SECRET s3_key_id WITH (value = "<key_ID>"); CREATE SECRET s3_secret_key WITH (value = "<secret_key>"); -
Create an external data source. To avoid changing the query text, name it the same as the connection in Yandex Query:
CREATE EXTERNAL DATA SOURCE <connection_name> WITH ( SOURCE_TYPE = "ObjectStorage", LOCATION = "https://storage.yandexcloud.net/<bucket_name>/", AUTH_METHOD = "AWS", AWS_ACCESS_KEY_ID_SECRET_PATH = "s3_key_id", AWS_SECRET_ACCESS_KEY_SECRET_PATH = "s3_secret_key", AWS_REGION = "ru-central1" );Secrets are not required for a public bucket: specify
AUTH_METHOD = "NONE"and do not specify theAWS_*parameters. -
Check that the database reads the bucket:
SELECT * FROM <connection_name>.`<path>/` WITH ( FORMAT = "csv_with_names", WITH_INFER = "true" ) LIMIT 10;
Transfer data bindings
For each binding, create an external table with the same columns, format, and compression:
CREATE EXTERNAL TABLE <binding_name> (
date Date NOT NULL,
service_name Utf8,
cost Double
) WITH (
DATA_SOURCE = "<connection_name>",
LOCATION = "<path>/",
FORMAT = "csv_with_names",
COMPRESSION = "gzip"
);
If partitioning or partition projection is configured in the binding, transfer the PARTITIONED_BY and projection.* parameters unchanged.
Transfer requests
Connection requests are migrated unchanged if the external source name matches the connection name. Remove the bindings. prefix from binding requests:
SELECT service_name, SUM(cost) AS total
FROM bindings.`billing`
WHERE date >= Date("2026-09-01")
GROUP BY service_name
ORDER BY total DESC;
SELECT service_name, SUM(cost) AS total
FROM billing
WHERE date >= Date("2026-09-01")
GROUP BY service_name
ORDER BY total DESC;
You can execute requests in the management console, or using the YDB CLI
ydb \
--endpoint <database_endpoint> \
--database <path_to_database> \
sql -s 'SELECT service_name, SUM(cost) AS total FROM billing GROUP BY service_name' \
--format csv > result.csv
Consider performance
The speed of a federated query is limited by the network throughput of the database nodes during reads from Object Storage. Yandex Query distributed reads across a shared pool of nodes; consequently, the same query may take longer to execute in a database with a small number of nodes. If speed is important, increase the number of database nodes or move the data to column-oriented tables.
Column-oriented tables: loading data into the database
If the same files are read repeatedly, e.g., by an auto-refreshing dashboard, upload them into a column-oriented table. Queries to the column-oriented table do not read the bucket again.
-
Create a column-oriented table:
CREATE TABLE billing_data ( date Date NOT NULL, resource_id Utf8 NOT NULL, service_name Utf8, cost Double, PRIMARY KEY (date, resource_id) ) PARTITION BY HASH(date, resource_id) WITH (STORE = COLUMN); -
Load data from the external table:
INSERT INTO billing_data SELECT date, resource_id, service_name, cost FROM billing; -
To load additional files, run the same query on a schedule with a filter based on date or path, e.g., from a Cloud Functions function with a timer trigger.
-
Switch queries and dashboards from the external table to
billing_data.
Database connections
Connections with Yandex Query, Managed Service for PostgreSQL, Managed Service for ClickHouse®, Managed Service for MySQL®, and Yandex MPP Analytics for PostgreSQL are migrated to external data sources of the appropriate type. The syntax of SELECT * FROM<source>.<table> queries does not change. Connection parameters are described in the Federated queries
Check the result
-
Execute each migrated query on the same set of files in Yandex Query and in the new solution.
-
Compare the number of rows and the checksums by the key columns:
SELECT COUNT(*) AS rows, SUM(cost) AS total_cost FROM billing WHERE date BETWEEN Date("2026-09-01") AND Date("2026-09-30"); -
Switch the dashboards, schedules, and applications that accessed Yandex Query to the new solution.
If something went wrong
|
Error or symptom |
What to check |
|
|
The database was created in serverless mode. Create a database with dedicated resources. |
|
|
The |
|
Data parsing error |
Column types and requirements in the schema. If the file does not contain a column with |
|
The request is taking longer to complete than in Yandex Query |
Number of database nodes. Use column-oriented tables for recurring queries. |
If you were unable to resolve the issue, contact support and attach the following:
- Database ID.
- Query text and the error text.
- Error time and the query ID, if there is one in the output.