DBT Jaffleshop Xebia BigQuery
- Create a python virtualenv (at least 3.8):
python3.8 -m venv .venv. Using conda or another virtual environment is fine too, but will not be assumed here. - Activate the virtualenv:
source .venv/bin/activatein Linux/Mac or on Windows.\venv\Scripts\activate. - Now using the venv, install the python requirements:
pip install -r requirements.txtthis will install dbt. - Now, if using
gcloudauthentication you should be fine. Using a credentials key file, you need to provide the path to this file inprofiles.yml:
method: service-account
keyfile: .creds/credentials.json
The .creds folder is in gitignore and should never be commited to Git!
- Run
dbt debugto check the connection to BigQuery. - Now we need to install the packages for dbt, run
dbt deps. - You are ready to go!
You can use the dbt-coves Python package to interactively choose and generate staging models and source files from the command line. The .dbt_coves folder contains custom templating to help generate the files.
Generate sources
- Run
dbt-coves generate sources. - Choose the source tables from BigQuery you want to create staging models for.
- The files should be automatically generated in the
models/staging/<source_name>folder along with a source YAML file.
Generate model properties We can also create a properties YAML for an existing model so you don't need to do that manually.
- Run
dbt-coves generate properties. - Choose the models from your schema in BigQuery.
- The properties YAML should be automatically generated in the same folder as the model.