YDB dialect plugin for sqlglot
Project description
ydb-sqlglot-plugin
YDB dialect plugin for sqlglot.
This package provides a YDB dialect for sqlglot, enabling SQL parsing and generation with YDB-specific syntax and features.
Installation
pip install ydb-sqlglot-plugin
Usage
After installing the package, the ydb dialect is automatically registered with sqlglot:
import sqlglot
# Transpile from another dialect to YDB
sql = "SELECT * FROM users WHERE id = 1"
result = sqlglot.transpile(sql, read="mysql", write="ydb")[0]
print(result)
# Output: SELECT * FROM `users` WHERE id = 1
# Parse directly with YDB dialect
parsed = sqlglot.parse_one("SELECT * FROM `users`", dialect="ydb")
print(parsed.sql(dialect="ydb"))
Features
- Table name escaping: Table names are automatically wrapped in backticks
- CTE to variables: Common Table Expressions are converted to YDB-style variables (
$name = (...)) - Date/Time functions: Proper mapping of date/time functions to YDB's DateTime module
- Type mapping: SQL types are mapped to YDB-specific types (e.g.,
VARCHAR→Utf8,INT→INT32) - Subquery decorrelation: Correlated subqueries are transformed into JOINs for better YDB compatibility
- Lambda expressions: Support for YDB-style lambda expressions in array operations
Development
Prerequisites
- Python 3.9+
- pip
Setup
Clone the repository and install in development mode:
git clone https://github.com/ydb-platform/ydb-sqlglot-plugin.git
cd ydb-sqlglot-plugin
# Create virtual environment (optional but recommended)
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install with dev dependencies
pip install -e ".[dev]"
Running Tests
pytest
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ydb_sqlglot_plugin-0.1.0.tar.gz.
File metadata
- Download URL: ydb_sqlglot_plugin-0.1.0.tar.gz
- Upload date:
- Size: 27.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
14c92bad99b635d2140d26c8481588675d02a7bff5113b37d0382f445ee37be5
|
|
| MD5 |
d3d88d16174f238695411591c9d2640e
|
|
| BLAKE2b-256 |
20c4ba90907b599e6c28dbbb554bda6ed4f96bee7f743d308d9aa0ecc4c92636
|
Provenance
The following attestation bundles were made for ydb_sqlglot_plugin-0.1.0.tar.gz:
Publisher:
python-publish.yml on ydb-platform/ydb-sqlglot-plugin
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ydb_sqlglot_plugin-0.1.0.tar.gz -
Subject digest:
14c92bad99b635d2140d26c8481588675d02a7bff5113b37d0382f445ee37be5 - Sigstore transparency entry: 820910094
- Sigstore integration time:
-
Permalink:
ydb-platform/ydb-sqlglot-plugin@f28dbdf7392a6696649945148b9d893b281eadac -
Branch / Tag:
refs/heads/main - Owner: https://github.com/ydb-platform
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@f28dbdf7392a6696649945148b9d893b281eadac -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file ydb_sqlglot_plugin-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ydb_sqlglot_plugin-0.1.0-py3-none-any.whl
- Upload date:
- Size: 22.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d7b4c467269f4170d3d508d42521487a5cbfd95993dc2128d2e51f8dc35d6cec
|
|
| MD5 |
81e9d6c909697ed0b3d660993355237f
|
|
| BLAKE2b-256 |
fafe536027f054d42df8132e4434db6ae409080609a99e01213e80886874becd
|
Provenance
The following attestation bundles were made for ydb_sqlglot_plugin-0.1.0-py3-none-any.whl:
Publisher:
python-publish.yml on ydb-platform/ydb-sqlglot-plugin
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ydb_sqlglot_plugin-0.1.0-py3-none-any.whl -
Subject digest:
d7b4c467269f4170d3d508d42521487a5cbfd95993dc2128d2e51f8dc35d6cec - Sigstore transparency entry: 820910098
- Sigstore integration time:
-
Permalink:
ydb-platform/ydb-sqlglot-plugin@f28dbdf7392a6696649945148b9d893b281eadac -
Branch / Tag:
refs/heads/main - Owner: https://github.com/ydb-platform
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@f28dbdf7392a6696649945148b9d893b281eadac -
Trigger Event:
workflow_dispatch
-
Statement type: