Registry / database / tree-sitter-sql-bigquery

tree-sitter-sql-bigquery

JSON →
library0.8.0jsnpmunverified

Tree-sitter grammar for GoogleSQL (BigQuery SQL dialect). Version 0.8.0, released 2024-04, maintained actively. Supports parsing BigQuery SQL using the tree-sitter parsing library, enabling incremental parsing, syntax highlighting, and code navigation. Differentiators: dedicated BigQuery dialect support, bindings for Node.js via tree-sitter, and a web demo. Active development with CI.

npm install tree-sitter-sql-bigquery
INSTALL
IMPORT
SIG · TREE-SITTER-SQL-BI
T
tree-sitter-sql-bigquery
databasejavascriptv0.8.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
✓ import Parser from 'tree-sitter'; import SQLBigQuery from 'tree-sitter-sql-bigquery'; const parser = new Parser(); parser.setLanguage(SQLBigQuery);
✗ const Parser = require('tree-sitter'); const SQLBigQuery = require('tree-sitter-sql-bigquery');
tree-sitter >=0.21 moves to ESM exports for Node.js
types
✓ import type { Tree } from 'tree-sitter'; import SQLBigQuery from 'tree-sitter-sql-bigquery';
TypeScript types included; import default for language object
Grammar (direct use)
✓ import { grammar } from 'tree-sitter-sql-bigquery';
If you need the grammar object directly (e.g., for custom parser). Not common; prefer setLanguage with default export.

Parses a BigQuery SQL statement using tree-sitter and prints the syntax tree.

import Parser from 'tree-sitter'; import SQLBigQuery from 'tree-sitter-sql-bigquery'; const parser = new Parser(); parser.setLanguage(SQLBigQuery); const source = `SELECT 1 AS a FROM dataset.table;`; const tree = parser.parse(source); console.log(tree.rootNode.toString());
Debug
Known issues
breakingtree-sitter peer dependency changed from ^0.20 to ^0.21 in v0.8.0
fix
Upgrade tree-sitter to ^0.21.0
affects: >=0.8.0
breakingESM-only imports in tree-sitter >=0.21; require() may fail
fix
Use import statement instead of require()
affects: >=0.8.0
gotchaGrammar may not be fully up-to-date with latest BigQuery features; check issue tracker
fix
Check GitHub issues; contribute if needed
affects: >=0.0.1
Errors
Common errors & fixes
Error: Cannot find module 'tree-sitter'
Missing peer dependency tree-sitter
fix
npm install tree-sitter
TypeError: Parser is not a constructor
Wrong import style (CommonJS vs ESM)
fix
Use import Parser from 'tree-sitter' with ESM or use the ESM variant for tree-sitter >=0.21
Error: Language function must be the language object, not a string
Passing module path string instead of language object to parser.setLanguage()
fix
parser.setLanguage(SQLBigQuery) not parser.setLanguage('tree-sitter-sql-bigquery')
Upgrade
Version history
0.8.0latest on npm
Audit
Dependencies
tree-sitterrequiredRuntime peer dependency for tree-sitter API
Agent activity
16 hits · last 30 days
node
14
Bingbot
1
OpenAI (training)
1
Resources
tree-sitter-sql-bigquery — npm install tree-sitter-sql-bigquery · libregistry