Generated Computers
Locals: an Apple Silicon engine that runs local LLMs up to 3x faster. A product of Generated Computers.
Translation pending
A multi-dialect SQL grammar for tree-sitter; ANSI base plus 22 dialect extensions.
Translation pending
Developer toolsJavaScript · C++GitHub @RelativelyUnknownOnlineOwner unconfirmed
Have you tried it? One tap is enough. No sign-in needed.
Owners of public repositories under a personal GitHub account can sign in to verify ownership and manage the introduction themselves. No administrator approval is needed.
Sign in, generate a verification file, and commit it to this repository’s default branch within 30 minutes. Files on other branches or forks do not count. Then check the file below to manage the project without administrator approval. Keep the file to retain your access.
If needed, you will go to sign-in. After signing in, return here and press your chosen verification button again.
Run /nomorevibe verify in your project folder to verify ownership and manage the introduction yourself.
Verify in one minuteAsk about other verification options
SQL grammar for tree-sitter
Translation pending
Taken from the repository README
Loading the full README.
Read the full README ↗SQL grammars for tree-sitter: a strict ANSI base and 22 dialects built on top of it. Each dialect is its own parser, so Postgres code is parsed as Postgres and T-SQL as T-SQL.
Forked from DerekStride/tree-sitter-sql, which mixes several dialects into one permissive grammar.
pip install tree-sitter-sql-polyglot
npm install @relativelyunknown/tree-sitter-sql-polyglot
cargo add tree-sitter-sql-polyglot --features postgres # or --features full for all 22
go get github.com/relativelyunknown/tree-sitter-sql-polyglot/bindings/go/postgres
Swift (SwiftPM) and C (CMake) are supported too. See the usage docs.
from tree_sitter import Language, Parser
import tree_sitter_sql
parser = Parser(Language(tree_sitter_sql.language_postgres()))
tree = parser.parse(b"SELECT id FROM users WHERE name ILIKE 'a%'")
import Parser from "tree-sitter";
import { postgres } from "@relativelyunknown/tree-sitter-sql-polyglot";
const parser = new Parser();
parser.setLanguage(postgres);
const tree = parser.parse("SELECT id FROM users WHERE name ILIKE 'a%'");
Only the dialects you use get compiled or loaded. Each one also ships its own highlights query
(HIGHLIGHTS_QUERY_POSTGRES in Python and Rust, postgres.HIGHLIGHTS_QUERY in Node).
| Dialect | Extends | Notable syntax |
|---|---|---|
| base | ANSI SQL: GROUPING SETS, OFFSET ... FETCH, WITHIN GROUP, GRANT/REVOKE | |
| postgres | base | COPY, VACUUM, :: casts, PARTITION OF, row-level security policies |
| cockroachdb | postgres | AS OF SYSTEM TIME, UPSERT, BACKUP/RESTORE, changefeeds |
| mysql | base | ENGINE=, index hints, SHOW, LIMIT offset, count, @@ variables |
| mariadb | mysql | system-versioned tables, RETURNING, INVISIBLE columns |
| sqlite | base | INSERT OR REPLACE, AUTOINCREMENT, INDEXED BY |
| oracle | base | PL/SQL blocks and packages, CONNECT BY, BULK COLLECT |
| db2 | base | SQL PL, modules, audit policies, federated objects |
| tsql | base | T-SQL scripting, CROSS APPLY, query hints, #temp tables |
| hana | base | column/row tables, UPSERT ... WITH PRIMARY KEY, SQLScript |
| teradata | base | SEL/DEL, PRIMARY INDEX, RANGE_N, COLLECT STATISTICS |
| bigquery | base | STRUCT<...>/ARRAY<...>, UNNEST, QUALIFY |
| spanner | bigquery | INTERLEAVE IN PARENT, change streams, row deletion policies |
| snowflake | base | scripting, LATERAL FLATTEN, time travel, @stage |
| redshift | base | DISTKEY/, external schemas, / |
A child dialect only adds what its engine adds; it gets the rest from its parent. How much of each engine's syntax is covered, checked against SQLGlot, ANTLR, pglast and sqlfluff, is on the coverage page.
You need Node and the tree-sitter CLI (npm install -g tree-sitter-cli).
npm install # unpacks the committed parsers and builds the Node addons
npm run generate # regenerate the base parser after editing grammar/
npm run generate -- postgres # or a single dialect
npm run generate:all # or everything
npm run test:corpus # base corpus tests
(cd postgres && npx tree-sitter test) # a dialect's corpus tests
A base grammar change affects every dialect, so regenerate and test all of them. Generation is
cached by file hash; npm run generate:force skips the cache.
CONTRIBUTING.md covers the workflow and AGENTS.md the grammar layout.
MIT. The git history from upstream is kept, so upstream authors show up in the contributors list;
CODEOWNERS lists who maintains this fork. LICENSE carries both copyright
notices.
SORTKEYCOPYUNLOAD| duckdb | base | FROM-first SELECT, EXCLUDE/REPLACE, lambdas, ASOF JOIN |
| clickhouse | base | ENGINE = MergeTree, PREWHERE, FINAL, ARRAY JOIN, LIMIT BY |
| trino | base | MATCH_RECOGNIZE, PREPARE/EXECUTE, lambdas, ROW types |
| athena | trino | UNLOAD ... TO 's3://...', MSCK REPAIR TABLE |
| flink | base | connector DDL, WATERMARK FOR, window TVFs, temporal joins |
| hive | base | LATERAL VIEW, STORED AS, multi-table INSERT |
| spark | hive | PIVOT, QUALIFY, scripting, Iceberg, VARIANT |
| databricks | spark | Delta OPTIMIZE/VACUUM, Unity Catalog, COPY INTO |