Skip to main content

tree-sitter-sql-polyglot

A multi-dialect SQL parser for tree-sitter. It provides an ANSI SQL base plus 22 independently compiled dialect grammars, each layered on top with tree-sitter's grammar(parent, overrides) composition.

The grammar is a fork of DerekStride/tree-sitter-sql. Upstream ships a single "permissive" grammar that mixes several dialects together. This fork splits that into a strict ANSI base and one grammar per dialect, so each engine's syntax is parsed on its own terms.

Docs site and dialect coverage, which carries the per-dialect feature scores and is regenerated from the live parsers on every push to main.


Dialects

Each dialect compiles to its own <dialect>/src/parser.c and can be used independently.

Dialect Extends Highlights
base (ANSI) none GRANT/REVOKE, GROUP BY ROLLUP/CUBE/GROUPING SETS, FETCH FIRST/OFFSET ... FETCH, WITHIN GROUP, TRIM(... FROM ...), interval qualifiers
hana base CREATE COLUMN/ROW TABLE, UPSERT ... WITH PRIMARY KEY, WITH HINT (...), SQLScript procedures (LANGUAGE SQLSCRIPT, DECLARE, :=, :param)
hive base LATERAL VIEW, STORED AS/STORED BY, multi-table INSERT, LOAD DATA INPATH, CLUSTER/DISTRIBUTE/SORT BY
spark hive QUALIFY, PIVOT/UNPIVOT, time travel, scripting (IF/WHILE/LOOP), Iceberg, VARIANT, CREATE TABLE ... USING/OPTIONS
databricks spark Delta/DLT (OPTIMIZE ... ZORDER BY, VACUUM, RESTORE), Unity Catalog (CATALOG/VOLUME/EXTERNAL LOCATION, GRANT), Iceberg CALL
postgres base COPY, VACUUM, PARTITION BY/PARTITION OF, CREATE TABLE (LIKE ...), INHERITS, extensions, RLS policies, :: cast
mysql base ENGINE=/CHARSET=, index hints, SHOW, DESCRIBE, LIMIT offset, count, @/@@ variables
mariadb mysql INVISIBLE columns (plus inherited MySQL features)
oracle base CONNECT BY, PL/SQL blocks, packages, cursors, FORALL, BULK COLLECT, numeric FOR ... IN 1..10
db2 base SQL PL (BEGIN...END, IF/WHILE/LOOP, LEAVE/ITERATE), modules, audit policies, federated objects
tsql base T-SQL scripting, CROSS/OUTER APPLY, query hints, #temp/##global identifiers
bigquery base INT64/STRUCT<...>/ARRAY<...> types, UNNEST, backtick identifiers, QUALIFY
snowflake base scripting, LATERAL FLATTEN, time travel, @stage sources, :: cast
sqlite base INSERT OR REPLACE/IGNORE, UPSERT, AUTOINCREMENT, INDEXED BY
spanner bigquery trailing PRIMARY KEY, INTERLEAVE IN PARENT ... ON DELETE CASCADE, NULL_FILTERED/STORING indexes, CREATE CHANGE STREAM, ROW DELETION POLICY, STRING(n|MAX)/BYTES(n|MAX)
duckdb base FROM-first SELECT, SELECT * EXCLUDE/REPLACE/RENAME, lambdas, struct/map/list literals, ASOF/POSITIONAL JOIN, ATTACH
teradata base SEL/DEL abbreviations, SET/MULTISET/VOLATILE tables, [UNIQUE] PRIMARY INDEX/NO PRIMARY INDEX, PARTITION BY RANGE_N/CASE_N, COLLECT STATISTICS, CREATE MACRO, TOP n, QUALIFY, :param references
trino base PREPARE/EXECUTE/DEALLOCATE, MATCH_RECOGNIZE, TABLESAMPLE BERNOULLI/SYSTEM, ARRAY/MAP/ROW types, lambdas
athena trino UNLOAD ... TO 's3://...', MSCK REPAIR TABLE ... PARTITIONS (managed Trino plus data-lake semantics)
redshift base DISTKEY/SORTKEY/DISTSTYLE/ENCODE, CREATE EXTERNAL SCHEMA/TABLE, COPY/UNLOAD, VACUUM REINDEX, APPROXIMATE COUNT
cockroachdb postgres AS OF SYSTEM TIME, UPSERT INTO, BACKUP/RESTORE, IMPORT INTO ... CSV DATA, CREATE CHANGEFEED, hash-sharded indexes (USING HASH), STORING (...), SHOW JOBS/GRANTS/DATABASES
clickhouse base ENGINE = MergeTree() ..., column MATERIALIZED/ALIAS/EPHEMERAL/CODEC/TTL, PREWHERE, FINAL, ARRAY JOIN, LIMIT n BY, SAMPLE, WITH TOTALS, QUALIFY, ORDER BY ... WITH FILL, LIMIT ... WITH TIES, INTO OUTFILE/FORMAT, ALTER ... UPDATE/DELETE, OPTIMIZE ... FINAL, CREATE DICTIONARY/LIVE VIEW, SYSTEM ..., Map/Tuple/Nested/LowCardinality/Nullable types
flink base connector DDL (WITH (...)), WATERMARK FOR, windowing TVFs (TUMBLE/HOP/CUMULATE), MATCH_RECOGNIZE, temporal joins, CREATE CATALOG, LOAD/UNLOAD MODULE, statement sets

Dependency chains: databricks -> spark -> hive -> base, mariadb -> mysql -> base, athena -> trino -> base, cockroachdb -> postgres -> base, and spanner -> bigquery -> base. The chains follow real dialect genealogy: CockroachDB is PostgreSQL-compatible by design, and Spanner and BigQuery share GoogleSQL. Regenerate the child when a parent grammar changes. See AGENTS.md for the full architecture.


Installation

Every dialect is compiled/loaded lazily in all six: importing or depending on the package never pulls in more than the base grammar until you actually ask for a specific dialect.

cargo add tree-sitter-sql-polyglot --features postgres   # or: --features full (all 22)
npm install @relativelyunknown/tree-sitter-sql-polyglot
pip install tree-sitter-sql-polyglot
go get github.com/relativelyunknown/tree-sitter-sql-polyglot/bindings/go/postgres
# Swift: add https://github.com/RelativelyUnknown/Tree-sitter-sql-polyglot as a package dependency
# CMake: cmake -B build -DTREE_SITTER_SQL_POSTGRES=ON && cmake --build build   (or no flag for base)
use tree_sitter_sql_polyglot::{LANGUAGE, LANGUAGE_POSTGRES};

let mut parser = tree_sitter::Parser::new();
parser.set_language(&LANGUAGE.into()).unwrap();            // base ANSI grammar
// parser.set_language(&LANGUAGE_POSTGRES.into()).unwrap(); // needs features = ["postgres"] or "full"

Each dialect's identifier (postgres, databricks, cockroachdb, ...) is the same everywhere it appears: Cargo feature, npm/Python/Go/Swift name. See the Usage page for full import examples in every language, the lazy-loading mechanism per binding, and the complete identifier reference.


Development

Prerequisites

npm install -g tree-sitter-cli

Workflow

# Regenerate the base parser after editing grammar.js or grammar/**/*.js
npm run generate

# Regenerate a single dialect (and its parent chain as needed)
npm run generate:spark

# Regenerate every parser (base + all 22 dialects)
npm run generate:all

# Run corpus tests for the base grammar
npm run test:corpus

# Run corpus tests for a specific dialect
npm run test:corpus:spark

# Check that base keywords are in sync with queries/highlights.scm
npm run test:keywords

Generation is hash-cached: npm run generate* skips tree-sitter generate when the relevant grammar sources are unchanged. Use npm run generate:force to bypass the cache.

Base grammar rules are split across grammar/ (e.g. grammar/statements/*.js, grammar/expressions.js, grammar/keywords.js). Dialect rules live under <dialect>/grammar/. A change to the base ripples to all 22 parsers, so regenerate and test all of them after editing base files.

See CONTRIBUTING.md and AGENTS.md for more detail.


References

Other SQL tree-sitter grammars


Fork history & attribution

This repo preserves the full git history of DerekStride/tree-sitter-sql, so GitHub's Contributors graph includes upstream authors alongside this fork's own. Current maintainership is CODEOWNERS. LICENSE carries both the original 2021 copyright notice and this fork's. General extensions are worth sending upstream if the maintainers there want them; vendor-specific ones stay here.

Metadata

Release files for tree-sitter-sql-polyglot 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tree-sitter-sql-polyglot 0.1.1
File Size Uploaded Provenance Actions
tree_sitter_sql_polyglot-0.1.1.tar.gz 17.3 MB With provenance Details for tree_sitter_sql_polyglot-0.1.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for tree-sitter-sql-polyglot 0.1.1
File Actions
tree_sitter_sql_polyglot-0.1.1-cp310-abi3-win_arm64.whl CPython 3.10 abi3 Windows ARM64 Details for tree_sitter_sql_polyglot-0.1.1-cp310-abi3-win_arm64.whl
tree_sitter_sql_polyglot-0.1.1-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for tree_sitter_sql_polyglot-0.1.1-cp310-abi3-win_amd64.whl
tree_sitter_sql_polyglot-0.1.1-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details for tree_sitter_sql_polyglot-0.1.1-cp310-abi3-musllinux_1_2_x86_64.whl
tree_sitter_sql_polyglot-0.1.1-cp310-abi3-musllinux_1_2_aarch64.whl CPython 3.10 abi3 Linux musl 1.2+ ARM64 Details for tree_sitter_sql_polyglot-0.1.1-cp310-abi3-musllinux_1_2_aarch64.whl
tree_sitter_sql_polyglot-0.1.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details for tree_sitter_sql_polyglot-0.1.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
tree_sitter_sql_polyglot-0.1.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64, Linux glibc 2.28+ ARM64 Details for tree_sitter_sql_polyglot-0.1.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
tree_sitter_sql_polyglot-0.1.1-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for tree_sitter_sql_polyglot-0.1.1-cp310-abi3-macosx_11_0_arm64.whl
tree_sitter_sql_polyglot-0.1.1-cp310-abi3-macosx_10_9_x86_64.whl CPython 3.10 abi3 macOS 10.9+ x86-64 Details for tree_sitter_sql_polyglot-0.1.1-cp310-abi3-macosx_10_9_x86_64.whl

Total release size: 76.4 MB

Release files / tree_sitter_sql_polyglot-0.1.1.tar.gz

Download URL tree_sitter_sql_polyglot-0.1.1.tar.gz
Size 17.3 MB
Tags Source
SHA-256 checksum
How to use checksums
562378437ac9c224e7422e3191387d8a30ba25648c071b08a79c43549329d7c2
BLAKE2b-256 checksum
How to use checksums
614cd080870198793ad58323d51d3448f2856e9a1bc6ecbe68d3fb8537b9c3fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.

Transparency log

Release files / tree_sitter_sql_polyglot-0.1.1-cp310-abi3-win_arm64.whl

Download URL tree_sitter_sql_polyglot-0.1.1-cp310-abi3-win_arm64.whl
Size 6.8 MB
Tags CPython 3.10 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
b68ae849b262835a49a469708fa63d29e92199161c93514ff7843e9a67ff4c51
BLAKE2b-256 checksum
How to use checksums
b36c4c58f6406ac3f69822a54091daac5fe8b5dbc425aed12380e81ccbece865
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.

Transparency log

Release files / tree_sitter_sql_polyglot-0.1.1-cp310-abi3-win_amd64.whl

Download URL tree_sitter_sql_polyglot-0.1.1-cp310-abi3-win_amd64.whl
Size 6.8 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
9b4add07c960bb5db78594426a9975f8298cff6cce7b2f86505e146d94fbe20f
BLAKE2b-256 checksum
How to use checksums
c21abe20af9cc8ba5327c82fac1c525383b26a78b508775e0778f037fabd126c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.

Transparency log

Release files / tree_sitter_sql_polyglot-0.1.1-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL tree_sitter_sql_polyglot-0.1.1-cp310-abi3-musllinux_1_2_x86_64.whl
Size 7.8 MB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
79338151c0a0939c2a23f606a40c7bfc1a456f10ffaf1bd80ac23264ca486ef5
BLAKE2b-256 checksum
How to use checksums
8dc89b578043a974559600ccaa83323fc9252621f4a38bf49c4edbf6c76c57ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.

Transparency log

Release files / tree_sitter_sql_polyglot-0.1.1-cp310-abi3-musllinux_1_2_aarch64.whl

Download URL tree_sitter_sql_polyglot-0.1.1-cp310-abi3-musllinux_1_2_aarch64.whl
Size 7.9 MB
Tags CPython 3.10 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
81b1f13898f1b2b1c1b1801a529e9e7ec19fb32f021d840d2cd15a9281693cf7
BLAKE2b-256 checksum
How to use checksums
feec75ad42017d4a36c4aae09199a493d00bcbdc5911e03048c042b051489807
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.

Transparency log

Release files / tree_sitter_sql_polyglot-0.1.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL tree_sitter_sql_polyglot-0.1.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 7.8 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
8e4d20bfc3ade6dca5ca7fc86f0e155ae3854df7a6f34238653dd67939189e28
BLAKE2b-256 checksum
How to use checksums
b02aa0fb48968577aac099203a89fb3e6ef440c0b9f068bfd4c7580854f45f03
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.

Transparency log

Release files / tree_sitter_sql_polyglot-0.1.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl

Download URL tree_sitter_sql_polyglot-0.1.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Size 7.9 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
4df11b7f89688f1511d5ac82dfcfef59674595abec199511d44d28ed649ebbba
BLAKE2b-256 checksum
How to use checksums
5e77e40dec1161d969ddb422940538ecff448ad103f59fc1699583a576331ece
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.

Transparency log

Release files / tree_sitter_sql_polyglot-0.1.1-cp310-abi3-macosx_11_0_arm64.whl

Download URL tree_sitter_sql_polyglot-0.1.1-cp310-abi3-macosx_11_0_arm64.whl
Size 7.3 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
b5d6d365285b1694e7396e44ada2a9b8d2abd5055eabea9057000fa6ba10e5e0
BLAKE2b-256 checksum
How to use checksums
ddfbdd5beb90ff5e0cbffcac081022f34491603d698c7cef2c10312bd3b3f609
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.

Transparency log

Release files / tree_sitter_sql_polyglot-0.1.1-cp310-abi3-macosx_10_9_x86_64.whl

Download URL tree_sitter_sql_polyglot-0.1.1-cp310-abi3-macosx_10_9_x86_64.whl
Size 6.8 MB
Tags CPython 3.10 abi3 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
3a0abc648abac155225225573e8bb855e5b940fef702be12d375d82470a25d01
BLAKE2b-256 checksum
How to use checksums
89fbc133619a69e51856f7d766515fd6f99f5bbfb97f20e06e7a7a08a7c9531e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.

Transparency log

Security for tree-sitter-sql-polyglot 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 9 files in this release have been uploaded with provenance metadata.

Select from 9 files

Attestation for tree_sitter_sql_polyglot-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

9 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page