Generated Computers
Locals: an Apple Silicon engine that runs local LLMs up to 3x faster. A product of Generated Computers.
翻译准备中
个人 GitHub 账号下公开仓库的所有者可以登录并验证所有权,自行管理介绍,无需管理员批准。
登录并生成验证文件,在 30 分钟内将其提交到此仓库的默认分支。其他分支或分叉仓库中的文件无效。然后在下方检查文件,即可无需管理员批准直接管理项目。请保留文件以维持管理权限。
如需登录,将前往登录页面。登录后请回到此处,再次点击所选的验证按钮。
在项目文件夹中运行 /nomorevibe verify,即可验证所有权并自行管理介绍。
一分钟完成验证SQL grammar for tree-sitter
翻译准备中
取自仓库 README
正在加载完整 README。
查看完整 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 |