A CLI tool to streamline dbt project development.
Project description
Breeze CLI Tool Documentation
Introduction
Breeze is a command-line interface (CLI) tool designed to streamline the development of dbt (Data Build Tool) projects. It automates the creation and management of dbt models, sources, and their associated YAML files. Additionally, it provides utilities to add tests to models and sources efficiently.
Table of Contents
- Installation
- Command Overview
- Build Commands
- Add Commands
- Templates
- Examples
- Best Practices
- Support and Contributions
- Conclusion
Installation
run pip install breeze-dbt-cli in your dbt projects virtual environment.
Command Overview
Breeze organizes its functionality into several command groups:
- build: Commands to generate models, YAML files, and sources.
- add: Commands to add tests to models or sources.
Use breeze --help to display the help message and list of available commands.
Build Commands
Commands under the build group help in creating models, YAML files, and sources.
breeze build model
Generate .sql files with a boilerplate SELECT statement for each model under models/folder_name/model_name/model_name.sql.
Usage
breeze build model [OPTIONS] PATH MODEL_NAMES...
Arguments
- PATH (required): The folder path where the models .sql files will be created. By default, .sql files get created under their own subdirectory named after the model within the path provided. To omit this behaviour and create .sql files directly in the path provided, use
--no-subfolderor-nflag. - MODEL_NAMES (required): One or more model names for which to generate
.sqlfiles.
Options
- --force, -f: Overwrite existing
.sqlfiles if they exist. - --template, -t: Path to a custom SQL template file.
- --no-subfolder, -n: If specified, the
.sqlfile will be created directly in the provided path instead of a subfolder named after the model.
Examples
- Generate
.sqlfiles formodel1andmodel2inmodels/stg/model1/andmodels/stg/model2/respectively:
breeze build model stg model1 model2
- Generate
.sqlfiles formodel1andmodel2in inmodels/stg/, without creating separate subfolders for each model:
breeze build model staging model1 model2 --no-subfolder
- Generate
.sqlfile formodel1inmodels/stg/model1/using a custom template located intemplates/model1_template.sqland overwrite existing file:
breeze build model stg model1 --template templates/model1_template.sql --force
breeze build yml
Generate YAML files for one or more models. The YAML file will be created in the same directory as the corresponding .sql file for the model.
Usage
breeze build yml [OPTIONS] MODEL_NAMES...
Arguments
- MODEL_NAMES (required): One or more model names for which to generate YAML files.
Options
- --force, -f: Overwrite existing files if they exist.
- --template, -t: Path to a custom YAML template file.
Examples
- Generate YAML files for
model1andmodel2:
breeze build yml model1 model2
- Generate
.ymlfile formodel1using a custom template located intemplates/model1_template.ymland overwrite existing file:
breeze build yml model1 --template templates/model1_template.yml --force
breeze build source
Generate YAML files for one or more sources. By default, the YAML file is created under models/schema_name/source_name.yml. However, you can specify a custom path using the --path flag.
Usage
breeze build source [OPTIONS] SCHEMA_NAME SOURCE_NAMES...
Arguments
- SCHEMA_NAME (required): The schema name of the sources.
- SOURCE_NAMES (required): One or more source names for which to generate YAML files.
Options
- --all, -a: Build YAML files for all sources in the schema.
- --force, -f: Overwrite existing files if they exist.
- --template, -t: Path to a custom YAML template file.
- --path, -p: Specify a custom directory where the source YAML file will be saved. If the path does not exist, it will be created.
Examples
- Generate source YAML files for
source1andsource2undermodels/schema_name/:
breeze build source my_schema source1 source2
- Generate source YAML file for
source1using a custom template located intempaltes/source_template.ymland save it inmodels/sources/postgres/:
breeze build source my_schema source1 --template tempaltes/source_template.yml --path sources/postgres
- Force overwrite an existing YAML for
source1inmodels/schema_name/source1.yml:
breeze build source raw source1 --force
- Write and force overwrite and all YAMLs for sources in
rawschema inmodels/schema_name/using the custom template located intempaltes/source_template.yml:
breeze build source raw --all --force --template tempaltes/source_template.yml
Add Commands
Commands under the add group assist in adding tests to models or sources.
breeze add test
Add one or more tests to a model or source. If columns are specified, the tests are added to those columns. If no columns are specified, the tests are added at the model or source level.
Usage
breeze add test [OPTIONS] TEST_NAMES...
Arguments
- TEST_NAMES (required): One or more test names to add (e.g.,
not_null,unique).
Options
- --model, -m: The model name to add the test(s) to.
- --source, -s: The source name to add the test(s) to.
- --columns, -c: Comma-separated column names to add the test(s) to.
Examples
- Add multiple tests to specific columns in a model:
breeze add test not_null unique --model customers --columns "customer_id, email"
- Add a test at the model level:
breeze add test unique --model orders
- Add multiple tests to specific columns in a source:
breeze add test not_null accepted_values --source status --columns status_code
Templates
Breeze allows you to use custom templates for generating .sql and .yml files. You can specify a custom template using the --template option with the build commands.
Template Placeholders
You can include the following placeholders in your templates:
- {{ model_name }}: Name of the model.
- {{ source_name }}: Name of the source table.
- {{ schema_name }}: Name of the schema.
- {{ database }}: Name of the database.
- {{ columns }}: List of columns (used in loops).
Within loops, each column has:
- {{ column.name }}: Column name.
- {{ column.data_type }}: Data type of the column.
Example Templates
Model YAML Template
version: 2
models:
- name: {{ model_name }}
description: 'Describe {{ model_name }} here.'
tags: []
columns:
{% for column in columns %}
- name: {{ column.name }}
data_type: {{ column.data_type }}
description: ''
# tests:
# - not_null
{% endfor %}
Source YAML Template
version: 2
sources:
- name: {{ schema_name }}
description: ''
database: {{ database }}
schema: {{ schema_name }}
tables:
- name: {{ source_name }}
description: ''
tags: []
columns:
{% for column in columns %}
- name: {{ column.name }}
data_type: {{ column.data_type }}
description: ''
# tests:
# - not_null
{% endfor %}
SQL Template
-- Custom SQL Template stg tables
WITH
source AS (
SELECT *
FROM {{ source('raw', 'source_name') }}
),
SELECT * FROM source
Best Practices
-
Run
dbt compileordbt buildbefore generating YAML files: This ensures that themanifest.jsonis up-to-date, which Breeze uses to gather model information. -
Use the
--forceflag cautiously: Overwriting existing files can lead to loss of manual changes. Ensure you have backups or use version control. -
Validate Generated Files: After generating or modifying files, validate the YAML syntax and dbt configurations.
-
Enclose Columns with Spaces in Quotes: When specifying columns with spaces in their names or spaces after commas, enclose the columns in quotes.
Support and Contributions
If you encounter issues or have suggestions for new features, please consider contributing to the project or opening an issue on the project's repository.
Conclusion
Breeze simplifies dbt project development by automating repetitive tasks and enforcing consistency across models and sources. By leveraging custom templates and automated test additions, you can focus on developing robust data transformations.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file breeze_dbt_cli-0.2.12.tar.gz.
File metadata
- Download URL: breeze_dbt_cli-0.2.12.tar.gz
- Upload date:
- Size: 18.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
600d9bcec37d1e0c190a0a28e74d59cb61da833444db6205e4e4c8feb8bb75cd
|
|
| MD5 |
775f2ce8592e14da8b52b465386ce3bc
|
|
| BLAKE2b-256 |
51b17cde9d91de5691b790833740d8bc9f6ae5a7c0a9bfdb9f83014ae579dd51
|
File details
Details for the file breeze_dbt_cli-0.2.12-py3-none-any.whl.
File metadata
- Download URL: breeze_dbt_cli-0.2.12-py3-none-any.whl
- Upload date:
- Size: 20.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f9781ca7094e6072c1718551f6e173d275f46c65e56febd2a930845d375719b6
|
|
| MD5 |
6ae68dd89ffca34afd2239cd617215e3
|
|
| BLAKE2b-256 |
9cd060bd148ce0dc05d30ab2e34265192ecd4a53e235b0702787109fc97075ac
|