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 |