A no-dependency Python SQL parser, transpiler, optimizer and engine that translates queries across 30+ SQL dialects.
tobilg/polyglot
Rust/WASM SQL transpiler that parses, generates, transpiles and formats SQL across more than 30 dialects, inspired by sqlglot.
- Stars
- 999
- Forks
- 76
- Open issues
- 0
- Last commit
- 3 days ago
What is it?
Polyglot converts SQL between more than 30 dialects, including PostgreSQL, MySQL, BigQuery, Snowflake, DuckDB, Trino and ClickHouse. It can parse SQL into a typed AST, generate SQL back from AST nodes, pretty-print queries, and run validation with syntax, semantic and schema-aware checks.
The core is written in Rust and is distributed as a Rust crate, a TypeScript/WASM SDK for Node.js and browsers, a Python package built with PyO3, a Go SDK over a C FFI library, and a portable WASI command module that exchanges JSON over stdin and stdout.
The project also provides column lineage with OpenLineage-compatible payloads and a compact query analysis API that reports projections, relations, CTEs and column usage. Its test suite runs against fixture cases extracted from sqlglot.
Key features
- 01Transpiles SQL between any pair of more than 30 dialects
- 02Parses SQL into a typed AST and generates SQL from it
- 03Formats and pretty-prints SQL with configurable guard limits
- 04Provides column lineage and OpenLineage-compatible JSON payloads
- 05Offers bindings for Rust, TypeScript, Python, Go and WASI
Use cases
- Migrating analytics queries from one warehouse dialect to another
- Translating SQL in a browser or Node.js app without a server round trip
- Adding SQL lineage or query analysis to a data platform
- Validating and formatting SQL in CI or developer tooling
Quick start
- 1
Install the TypeScript SDK with npm
npm install @polyglot-sql/sdk - 2
Transpile MySQL SQL to PostgreSQL in TypeScript
- 3
Alternatively, install the Python package
pip install polyglot-sql
Things to know
- The WASI command module is described as experimental.
- The Go SDK needs a separately built native FFI library at runtime.
In collections
Topics
FAQ
- What is polyglot?
- Rust/WASM SQL transpiler that parses, generates, transpiles and formats SQL across more than 30 dialects, inspired by sqlglot. Polyglot converts SQL between more than 30 dialects, including PostgreSQL, MySQL, BigQuery, Snowflake, DuckDB, Trino and ClickHouse. It can parse SQL into a typed AST, generate SQL back from AST nodes, pretty-print queries, and run validation with syntax, semantic and schema-aware checks.
- Is polyglot free to use? What license does it have?
- polyglot is open source under the MIT license. Check the license terms before using it in commercial products.
- Is polyglot still maintained?
- Actively maintained. The last commit to polyglot was on Nov 3, 2026.
- What can I use polyglot for?
- Migrating analytics queries from one warehouse dialect to another Translating SQL in a browser or Node.js app without a server round trip Adding SQL lineage or query analysis to a data platform Validating and formatting SQL in CI or developer tooling
- How do I install polyglot?
- Install the TypeScript SDK with npm: npm install @polyglot-sql/sdk Transpile MySQL SQL to PostgreSQL in TypeScript Alternatively, install the Python package: pip install polyglot-sql
- Where can I get polyglot?
- The source code and installation instructions are on GitHub: https://github.com/tobilg/polyglot
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A Java SQL parser that turns SQL statements into a traversable tree of Java objects and can render them back to SQL text.
A Go library and CLI that parses ClickHouse-dialect SQL into a typed AST and formats or beautifies queries.
A drop-in Apache Spark replacement written in Rust that runs existing PySpark code over the Spark Connect protocol.
A unified analytics engine for large-scale data processing, with APIs in Scala, Java, Python and R.
Self-hosted, notebook-style environment for building, scheduling and debugging data pipelines in Python, SQL or R.