---
metadata:
  - name: generator
    content: Diplodoc Platform v5.52.0
alternate:
  - https://ydb.tech/docs/en/integrations/sql-translation/sql-dialect-converter.md
  - https://ydb.tech/docs/ru/integrations/sql-translation/sql-dialect-converter.md
  - href: en/integrations/sql-translation/sql-dialect-converter.md
    type: text/markdown
    title: Markdown version
  - href: ../../llms.txt
    type: text/markdown
    title: llms.txt
sourcePath: en/core/integrations/sql-translation/sql-dialect-converter.md
---
> **Documentation Index:** Fetch the complete configuration index at https://ydb.tech/docs/en/llms.txt

# SQL dialect converter to YQL

The SQL dialect converter is a service that converts SQL queries written in other dialects (PostgreSQL, MySQL, ClickHouse, and others) into [YQL](https://ydb.tech/docs/en/yql/reference/index.md) syntax. The service is designed to simplify migration of existing queries to YDB and lower the entry barrier for developers already familiar with other DBMSs.

The converter is available as a standalone web application at [ydb-dialect-converter.website.yandexcloud.net](https://ydb-dialect-converter.website.yandexcloud.net/), and is also built into the [DBeaver plugin for YDB](https://ydb.tech/docs/en/integrations/gui/dbeaver-plugin.md#convert-dialect) and the [VS Code plugin for YDB](https://ydb.tech/docs/en/integrations/gui/vscode-plugin.md). The user pastes a query in the source dialect, selects the dialect from the list, and gets a version of the same query in YQL.

## How to use {#usage}

1. Open the [converter web interface](https://ydb-dialect-converter.website.yandexcloud.net/).
2. Select the source SQL dialect from the drop-down list.
3. Paste the query into the **Input SQL query** field. If necessary, use the ready-made examples (`CTE Example`, `Create Table Example`, and others).
4. Click **Convert** — the YQL result will appear in the **Conversion result (YDB)** field.

## How it works {#principles}

The conversion is performed in three stages:

1. **Parsing the source SQL.** The source query is parsed by the specific dialect parser into an abstract syntax tree (AST) — a structure that describes the query's meaning independently of syntax.
2. **AST transformation.** Constructs specific to the source dialect are replaced with their YQL equivalents. For example, type casting functions, date and string handling, `LIMIT`/`OFFSET` operators, and `WITH` constructs are adapted to YQL rules.
3. **YQL generation.** A textual representation of the query in YQL is generated from the modified AST.

The stages are implemented using the [SQLGlot](https://github.com/tobymao/sqlglot) library and the [YDB plugin for it](https://ydb.tech/docs/en/integrations/sql-translation/sqlglot.md), which adds a separate YDB dialect to SQLGlot. SQLGlot is an open-source SQL parser and transpiler that supports over twenty dialects. It serves both as the parser for the source query and as the YQL generator.

If you need not a one-time conversion in the GUI but to embed the transformation into your own code or data processing pipeline, use the plugin directly — see the [SQLGlot](https://ydb.tech/docs/en/integrations/sql-translation/sqlglot.md) article.

{% note warning %}

The source query is sent to an external HTTPS service. Do not send queries containing confidential data (personal data, trade secrets, identifiers of real objects in production) to the converter.

{% endnote %}

## Supported dialects {#dialects}

The list of source dialects is determined by the set supported by SQLGlot. Among the main ones:

- PostgreSQL
- MySQL
- ClickHouse
- Microsoft SQL Server (T-SQL)
- Oracle
- Snowflake
- BigQuery
- Presto / Trino
- Spark SQL / Databricks
- SQLite

The current full list of dialects can be obtained via the converter API or viewed in the [SQLGlot source code](https://github.com/tobymao/sqlglot/tree/main/sqlglot/dialects). The target dialect is always YQL.

## Supported constructs {#supported-constructs}

The converter covers typical constructs of analytical and OLTP queries:

- SELECT operators: `SELECT`, `JOIN` (all types), `WHERE`, `GROUP BY`, `HAVING`, `ORDER BY`, `LIMIT`, `OFFSET`.
- Window functions (`OVER`, `PARTITION BY`, `ROWS BETWEEN`).
- Subqueries and CTE (`WITH`).
- Type casting (`CAST`, `::`), arithmetic and logical operations.
- Functions for strings, numbers, dates, and time — mapped to the nearest equivalent in YQL.
- Aggregate functions (`COUNT`, `SUM`, `AVG`, `MIN`, `MAX`, and others).
- DML operations: `INSERT`, `UPDATE`, `DELETE` (taking into account [transaction features of YDB](https://ydb.tech/docs/en/concepts/transactions.md)).

## Limitations {#limitations}

Full automatic conversion is not always possible, since YQL and other SQL dialects differ in data models and operation semantics. In particular:

- **Dialect-specific functions.** Functions that have no direct equivalent in YQL (for example, PostgreSQL arrays, `JSON_EXTRACT` MySQL with special path syntax) are translated to approximate equivalents or left for manual refinement.
- **Stored procedures and triggers.** Not supported, as YDB uses a different model for executing code in the database.
- **Dialect-specific DDL.** `CREATE TABLE` for complex types may require manual adjustment considering [columnar and row-based tables](https://ydb.tech/docs/en/concepts/datamodel/table.md) in YDB.
- **Optimizer hints.** Ignored: the YDB optimizer has its own control mechanisms.

The conversion result should be considered a draft: complex queries require manual review and adaptation before execution.

## See also {#see-also}

- [SQL dialect converter web interface](https://ydb-dialect-converter.website.yandexcloud.net/)
- [SQLGlot](https://ydb.tech/docs/en/integrations/sql-translation/sqlglot.md)
- [Connecting to YDB using the DBeaver plugin](https://ydb.tech/docs/en/integrations/gui/dbeaver-plugin.md)
- [YQL Reference](https://ydb.tech/docs/en/yql/reference/index.md)
- [SQLGlot](https://github.com/tobymao/sqlglot)
