dbt Wizard
This extension will help you work with dbt.
Also, it provides additional features like Highlighting errors, Completion for SQL, etc., for BigQuery data warehouses.
Note: Turning on Auto Save is strongly recommended. With this option turned on, VS Code will save your changes after a configured delay or when the focus leaves the editor. This feature is required for preview, completion, and error highlighting.
Table of Contents
Features
Go to definition
Macros

Models

Sources

Highlighting errors

Signature help

Completion for SQL

Completion for dbt
Macros

Models

Sources

dbt compile preview


How to use
The extension works on MacOS, Linux, and Windows (for Windows, see the additional steps in the Windows Support article). It supports the default locations for profiles.yml
and dbt_project.yml
files.
Prior to using the extension, you need to perform the following steps (note: replace dbt-bigquery with your adapter, such as dbt-postgres):
- Install bigquery-dbt and dbt-rpc (e.g.,
python3 -m pip install dbt-bigquery dbt-rpc
).
- In Terminal, test that dbt-rpc works by running the
dbt-rpc --version
command or specifying the Python environment for VS Code that was used to install dbt (e.g., ~/dbt-env/bin/python3
).
- Create a file named
profiles.yml
in the ~/.dbt/
folder and add a profile.
- Open the dbt project in the new VS Code window.
- Now you can open your model and see the dbt compile preview by right-clicking the code and choosing Show query preview from the context menu.
Profiles
You can use this extension with any data warehouse which is supported by dbt. See Available adapters.
BigQuery Profile
A BigQuery profile can be set up using one of the following authentication methods:
OAuth via gcloud
An example of /Users/user/.dbt/profiles.yml
using the OAuth via gcloud authorization type:
my-bigquery-db:
target: prod
outputs:
prod:
type: bigquery
method: oauth
project: google-test-project-id-400
dataset: dbt_default
threads: 4
Oauth Token-Based
An example of /Users/user/.dbt/profiles.yml
using the Oauth Token-Based authorization type:
Refresh token
my-bigquery-db:
target: prod
outputs:
prod:
type: bigquery
method: oauth-secrets
project: google-test-project-id-400
dataset: dbt_default
threads: 4
refresh_token: [refresh token]
client_id: [client id]
client_secret: [client secret]
token_uri: https://oauth2.googleapis.com/token
Temporary token
my-bigquery-db:
target: prod
outputs:
prod:
type: bigquery
method: oauth-secrets
project: google-test-project-id-400
dataset: dbt_default
threads: 4
token: [temporary access token]
Service Account File
An example of /Users/user/.dbt/profiles.yml
using the Service Account File authorization type:
my-bigquery-db:
target: prod
outputs:
prod:
type: bigquery
method: service-account
project: google-test-project-id-400
keyfile: /Users/user/.dbt/google-test-project-id-400.json
dataset: dbt_default
threads: 4
Service Account JSON
An example of /Users/user/.dbt/profiles.yml
using the Service Account JSON authorization type:
my-bigquery-db:
target: prod
outputs:
prod:
type: bigquery
method: service-account-json
project: google-test-project-id-400
dataset: dbt_default
threads: 4
# These fields come from the service account json keyfile
keyfile_json:
type: service_account
project_id: google-test-project-id-400
private_key_id: ...
private_key: |
-----BEGIN PRIVATE KEY-----
...
-----END PRIVATE KEY-----
client_email: test-bigquery@google-test-project-id-400.iam.gserviceaccount.com
client_id: ...
auth_uri: https://accounts.google.com/o/oauth2/auth
token_uri: https://oauth2.googleapis.com/token
auth_provider_x509_cert_url: https://www.googleapis.com/oauth2/v1/certs
client_x509_cert_url: https://www.googleapis.com/robot/v1/metadata/x509/test-bigquery%40google-test-project-id-400.iam.gserviceaccount.com
Issues
If you have found any bug, have an idea or suggestion on how to improve extension, please file an issue and provide the details here: Issues