BigQuery support for Emacs SQLi mode. Connects to Google’s bq CLI shell
and provides syntax highlighting, tab completion, and quote-aware query
transformations.
Requires Emacs 25.1+ and the Google Cloud SDK (bq must be in your PATH).
(straight-use-package '(sql-bigquery :type git :host github :repo "regadas/sql-bigquery"))(use-package sql-bigquery
:straight (:host github :repo "regadas/sql-bigquery"))Clone the repo and add it to your load-path:
(add-to-list 'load-path "/path/to/sql-bigquery")
(require 'sql-bigquery)- Authenticate with Google Cloud:
gcloud auth login - Start a BigQuery shell:
M-x sql-bigqueryYou will be prompted for a project ID (the
databaselogin parameter). - Open a
.sqlfile, set the product to BigQuery:M-x sql-set-product RET bigquery RET - Send queries to the shell:
Key binding Command Description C-c C-bsql-send-bufferSend the entire buffer C-c C-rsql-send-regionSend the selected region C-c C-csql-send-paragraphSend the current paragraph For queries with blank-line-separated CTEs, use
C-c C-bor select the full query withC-c C-rto avoid paragraph splitting.
Five-tier font-lock covering BigQuery types, constants, keywords, 100+ builtin functions (aggregates, date/time, string, regex, JSON, geography, window/analytic, math, hash, net), and clause modifiers.
Schema and table name completion via INFORMATION_SCHEMA queries.
The input filter pipeline collapses multi-line queries and converts line
comments (--) to block comments (/* */) before sending to bq shell.
It correctly preserves content inside:
- Single-quoted strings (
'hello') - Double-quoted strings (
"hello") - Triple-quoted strings (
'''multi\nline''') - Backtick-quoted identifiers (
`project.dataset.table`)
Switch the output format for future sessions:
M-x sql-bigquery-set-format
Options: pretty, json, csv, sparse, prettyjson.
| Variable | Default | Description |
|---|---|---|
sql-bigquery-program | "bq" | Path to the bq executable |
sql-bigquery-login-params | (database) | Login parameters prompted for |
sql-bigquery-options | ("--quiet" "--format" "pretty") | CLI options for bq shell |
GPL v3 — see LICENSE.