{"id":45546038,"url":"https://github.com/tobilg/duckdb-polyglot","last_synced_at":"2026-02-23T04:48:14.507Z","repository":{"id":339017531,"uuid":"1157327828","full_name":"tobilg/duckdb-polyglot","owner":"tobilg","description":"Use other SQL dialects in DuckDB ","archived":false,"fork":false,"pushed_at":"2026-02-17T15:30:24.000Z","size":138,"stargazers_count":7,"open_issues_count":3,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-17T20:28:20.681Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tobilg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-13T17:36:02.000Z","updated_at":"2026-02-17T19:37:41.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/tobilg/duckdb-polyglot","commit_stats":null,"previous_names":["tobilg/duckdb-polyglot"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/tobilg/duckdb-polyglot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobilg%2Fduckdb-polyglot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobilg%2Fduckdb-polyglot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobilg%2Fduckdb-polyglot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobilg%2Fduckdb-polyglot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tobilg","download_url":"https://codeload.github.com/tobilg/duckdb-polyglot/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobilg%2Fduckdb-polyglot/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29738081,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-23T04:36:46.119Z","status":"ssl_error","status_checked_at":"2026-02-23T04:36:25.794Z","response_time":90,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-02-23T04:48:13.928Z","updated_at":"2026-02-23T04:48:14.500Z","avatar_url":"https://github.com/tobilg.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DuckDB Polyglot Extension\n\nA DuckDB extension that provides SQL transpilation and analysis capabilities, powered by the [polyglot-sql](https://crates.io/crates/polyglot-sql) crate. It can transpile SQL between 34 different dialects, validate SQL, parse SQL into AST (JSON), optimize queries, trace column lineage, and diff SQL statements.\n\n## Installation\nYou can install this extension from the community extension repo like this:\n\n```sql\nINSTALL polyglot FROM community;\nLOAD polyglot;\n```\n\n## Functions\n\n### `polyglot_transpile(sql VARCHAR, from_dialect VARCHAR [, to_dialect VARCHAR]) -\u003e VARCHAR`\n\nTranspiles a SQL query from the given dialect to DuckDB SQL (default), or to any other supported dialect when `to_dialect` is specified.\n\n```sql\n-- Transpile to DuckDB (default)\nSELECT polyglot_transpile('SELECT NOW()', 'postgresql');\n\n-- Transpile between arbitrary dialects\nSELECT polyglot_transpile('SELECT DATEDIFF(''day'', ''2020-01-01'', ''2025-10-12'')', 'snowflake', 'postgresql');\n```\n\nIf the input contains multiple statements, they are joined with `;\\n` in the result.\n\n### `polyglot_dialects() -\u003e TABLE(dialect_name VARCHAR)`\n\nReturns a table of all 34 supported dialect names.\n\n```sql\nSELECT * FROM polyglot_dialects();\n```\n\n```\n┌──────────────┐\n│ dialect_name │\n│   varchar    │\n├──────────────┤\n│ athena       │\n│ bigquery     │\n│ clickhouse   │\n│ cockroachdb  │\n│ databricks   │\n│ datafusion   │\n│ doris        │\n│ dremio       │\n│ drill        │\n│ druid        │\n│ duckdb       │\n│ dune         │\n│ exasol       │\n│ fabric       │\n│ generic      │\n│ hive         │\n│ materialize  │\n│ mysql        │\n│ oracle       │\n│ postgresql   │\n│ presto       │\n│ redshift     │\n│ risingwave   │\n│ singlestore  │\n│ snowflake    │\n│ solr         │\n│ spark        │\n│ sqlite       │\n│ starrocks    │\n│ tableau      │\n│ teradata     │\n│ tidb         │\n│ trino        │\n│ tsql         │\n├──────────────┤\n│   34 rows    │\n└──────────────┘\n```\n\nSome dialects also accept aliases (e.g. `postgres` for `postgresql`, `mssql` or `sqlserver` for `tsql`, `memsql` for `singlestore`).\n\n### `polyglot_validate(sql VARCHAR, dialect VARCHAR) -\u003e STRUCT(valid BOOLEAN, message VARCHAR, line INTEGER, col INTEGER)`\n\nValidates a SQL statement against the given dialect's grammar. Returns a struct indicating whether the SQL is valid, and if not, the first error's details.\n\n```sql\nSELECT polyglot_validate('SELECT 1', 'generic');\n-- {'valid': true, 'message': '', 'line': 0, 'col': 0}\n\nSELECT polyglot_validate('SLECT 1', 'generic');\n-- {'valid': false, 'message': Invalid expression / Unexpected token, 'line': 0, 'col': 0}\n```\n\n### `polyglot_parse(sql VARCHAR, dialect VARCHAR) -\u003e JSON`\n\nParses a SQL statement into an AST and returns it as a JSON string.\n\n```sql\nSELECT polyglot_parse('SELECT 1', 'generic');\n-- Returns a JSON array of parsed AST expressions\n```\n\n### `polyglot_optimize(sql VARCHAR, dialect VARCHAR) -\u003e VARCHAR`\n\nParses a SQL statement, applies simplification and canonicalization optimization passes, and returns the optimized SQL string.\n\n```sql\nSELECT polyglot_optimize('SELECT a FROM t WHERE b = 1', 'generic');\n-- SELECT a FROM t WHERE b = 1\n```\n\n### `polyglot_query(sql VARCHAR, from_dialect VARCHAR) -\u003e TABLE`\n\nTranspiles a SQL query from the given dialect to DuckDB SQL, then executes it and returns the results. The output schema is dynamic, matching the columns of the executed query.\n\n```sql\nSELECT * FROM polyglot_query('SELECT 1 AS a, 2 AS b', 'postgresql');\n```\n\n```\n┌───┬───┐\n│ a │ b │\n├───┼───┤\n│ 1 │ 2 │\n└───┴───┘\n```\n\n### `polyglot_lineage(sql VARCHAR, dialect VARCHAR, column_name VARCHAR) -\u003e TABLE(node_name VARCHAR, source_table VARCHAR)`\n\nTraces the lineage of a column through a SQL statement, returning the dependency graph as a table of nodes.\n\n```sql\nSELECT * FROM polyglot_lineage('SELECT a FROM t', 'generic', 'a');\n```\n\n```\n┌───────────┬──────────────┐\n│ node_name │ source_table │\n├───────────┼──────────────┤\n│ a         │              │\n│ t.a       │              │\n└───────────┴──────────────┘\n```\n\n### `polyglot_diff(source_sql VARCHAR, target_sql VARCHAR, dialect VARCHAR) -\u003e TABLE(edit_type VARCHAR, expression VARCHAR)`\n\nComputes the diff between two SQL statements, returning each edit (insert, remove, move, update) as a row.\n\n```sql\nSELECT * FROM polyglot_diff('SELECT a FROM t', 'SELECT b FROM t', 'generic');\n```\n\n```\n┌───────────┬────────────┐\n│ edit_type │ expression │\n├───────────┼────────────┤\n│ remove    │ a          │\n│ insert    │ b          │\n└───────────┴────────────┘\n```\n\n## Building\n\n### Dependencies\n\n- [Rust toolchain](https://rustup.rs/)\n- Python3 + Python3-venv\n- [Make](https://www.gnu.org/software/make)\n- Git\n\n### Build steps\n\nClone the repo with submodules:\n\n```shell\ngit clone --recurse-submodules \u003crepo\u003e\n```\n\nConfigure (sets up Python venv with DuckDB test runner):\n\n```shell\nmake configure\n```\n\nBuild debug:\n\n```shell\nmake debug\n```\n\nBuild release:\n\n```shell\nmake release\n```\n\n## Running\n\nStart DuckDB with the `-unsigned` flag (required for locally built extensions):\n\n```shell\nduckdb -unsigned\n```\n\nThen load the extension:\n\n```sql\nLOAD 'build/debug/polyglot.duckdb_extension';\n\nSELECT polyglot_transpile('SELECT NOW()', 'postgresql');\nSELECT * FROM polyglot_dialects();\nSELECT * FROM polyglot_query('SELECT 1 AS a, 2 AS b', 'generic');\nSELECT polyglot_validate('SELECT 1', 'generic');\nSELECT polyglot_parse('SELECT 1', 'generic');\nSELECT polyglot_optimize('SELECT a FROM t WHERE b = 1', 'generic');\nSELECT * FROM polyglot_lineage('SELECT a FROM t', 'generic', 'a');\nSELECT * FROM polyglot_diff('SELECT a FROM t', 'SELECT b FROM t', 'generic');\n```\n\n## Testing\n\nTests are written in SQLLogicTest format in `test/sql/polyglot.test`.\n\n```shell\nmake test_debug\n```\n\nOr for release builds:\n\n```shell\nmake test_release\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftobilg%2Fduckdb-polyglot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftobilg%2Fduckdb-polyglot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftobilg%2Fduckdb-polyglot/lists"}