dbt™️-checkpoint hooks
What is dbt™️-checkpoint?
dbt™️-checkpoint is a collection of pre-commit hooks specifically designed for dbt™️ projects. It helps maintain consistent standards and catch common issues in your dbt™️ models before they get committed to your repository.
Why use dbt™️-checkpoint?
Ensures consistent dbt™️ model standards
Catches common dbt™️ issues early
Validates your dbt™️ project structure
Only checks files that have changed
Makes code reviews easier by catching issues automatically
Setting dbt™️ project root
You can specify a dbt™️ project root directory for all hooks. This is particularly useful when your dbt™️ project is not located at the root of your repository but in a sub-directory of it.
Create a .dbt-checkpoint.yaml
in the root of your repository and add the config dbt-project-dir
.
This way, we will automatically look for the required manifest/catalog inside your my_dbt_project
project folder.
Hooks
dbt™️-checkpoint provides an extensive set of pre-commit hooks for dbt™️ projects.
Start with basic checks like model properties and tests, then gradually add more specific checks as your project grows and customize them to match your team's standards.
Most hooks require running dbt parse
first, so make sure your dbt™️ environment is properly set up.
Model checks
check-column-desc-are-same
: Check column descriptions are the same.check-column-name-contract
: Check column name abides to contract.check-model-columns-have-desc
: Check the model columns have description.check-model-has-all-columns
: Check the model has all columns in the properties file.check-model-has-contract
: Check the model has contract enforced.check-model-has-constraints
: Check the model has specific constraints defined.check-model-has-description
: Check the model has description.check-model-has-meta-keys
: Check the model has keys in the meta part.check-model-has-labels-keys
: Check the model has keys in the labels part.check-model-has-properties-file
: Check the model has properties file.check-model-has-tests-by-name
: Check the model has a number of tests by test name.check-model-has-tests-by-type
: Check the model has a number of tests by test type.check-model-has-tests-by-group
: Check the model has a number of tests from a group of tests.check-model-has-tests
: Check the model has a number of tests.check-model-name-contract
: Check model name abides to contract.check-model-parents-and-childs
: Check the model has a specific number (max/min) of parents or/and childs.check-model-parents-database
: Check the parent model has a specific database.check-model-parents-name-prefix
: Check the parent model names have a specific prefix.check-model-parents-schema
: Check the parent model has a specific schema.check-model-tags
: Check the model has valid tags.check-model-materialization-by-childs
: Check the materialization of models given a threshold of child models.
Script checks
check-script-semicolon
: Check the script does not contain a semicolon.check-script-has-no-table-name
: Check the script has not table name (is not usingsource()
orref()
macro for all tables).check-script-ref-and-source
: Check the script has only existing refs and sources.
Source checks
check-source-columns-have-desc
: Check for source column descriptions.check-source-has-all-columns
: Check the source has all columns in the properties file.check-source-table-has-description
: Check the source table has description.check-source-has-freshness
: Check the source has the freshness.check-source-has-loader
: Check the source has loader option.check-source-has-meta-keys
: Check the source has keys in the meta part.check-source-has-labels-keys
: Check the source has keys in the labels part.check-source-has-tests-by-group
: Check the source has a number of tests from a group of tests.check-source-has-tests-by-name
: Check the source has a number of tests by test name.check-source-has-tests-by-type
: Check the source has a number of tests by test type.check-source-has-tests
: Check the source has a number of tests.check-source-tags
: Check the source has valid tags.check-source-childs
: Check the source has a specific number (max/min) of childs.
Macro checks
check-macro-has-description
: Check the macro has description.check-macro-arguments-have-desc
: Check the macro arguments have description.
Modifiers
generate-missing-sources
: If any source is missing this hook tries to create it.generate-model-properties-file
: Generate model properties file.unify-column-description
: Unify column descriptions across all models.replace-script-table-names
: Replace table names withsource()
orref()
macros in the script.remove-script-semicolon
: Remove the semicolon at the end of the script.
dbt™️ commands
dbt-clean
: Rundbt clean
command.dbt-compile
: Rundbt compile
command.dbt-deps
: Rundbt deps
command.dbt-docs-generate
: Rundbt docs generate
command.dbt-parse
: Rundbt parse
command.dbt-run
: Rundbt run
command.dbt-test
: Rundbt test
command.
dbt™️ checks
check-macro-has-meta-keys
: ensures that the macro has a list of valid meta keys. (usuallyschema.yml
).check-seed-has-meta-keys
: ensures that the seed has a list of valid meta keys. (usuallyschema.yml
).check-snapshot-has-meta-keys
: ensures that the snapshot has a list of valid meta keys. (usuallyschema.yml
).check-test-has-meta-keys
: ensures that the test has a list of valid meta keys. (usuallyschema.yml
).check-database-casing-consistency
: compare Manifest and Catalog to ensure DB and Schemas have the same casing.
Last updated