check-column-desc-are-same
What it doesCheck the models have the same descriptions for the same column names.When to use itE.g. in two of your models, you have
customer_id with the description This is cutomer_id, but there is one model where column customer_id has a description Something else. This hook finds discrepancies between column descriptions.--ignore: columns for which do not check whether have a different description.
Example
1 It means that you need to run
dbt parse before run this hook (dbt >= 1.5).2 It means that you need to run
dbt docs generate before run this hook.
How it works
- Hook takes all changed
ymlandSQLfiles. - The model name is obtained from the
SQLfile name. - The manifest is scanned for a model.
- Modified
ymlfiles are scanned for a model. - If any column in the found model has different descriptions than others, the hook fails.
- The description must be in either the yml file or the manifest.
check-column-name-contract
What it doesCheck that column name abides to a contract, as described in this blog post by Emily Riederer. A contract consists of a regex pattern and a series of data types.When to use itYou want to make sure your columns follow a contract, e.g. all your boolean columns start with the prefixes
is_, has_ or do_.--pattern: Regex pattern to match column names. --dtypes: Data types. --exclude: Regex pattern to exclude files.
Example
-- as the last argument. Otherwise pre-commit would not be able to separate a list of files with args.
Requirements
1 It means that you need to run
dbt parse before run this hook (dbt >= 1.5).2 It means that you need to run
dbt docs generate before run this hook.
How it works
- Hook takes all changed
SQLfiles. - The model name is obtained from the
SQLfile name. - The catalog is scanned for a model.
- If any column in the found model matches the regex pattern and it’s data type does not match the contract’s data type, the hook fails.
- If any column in the found model matches the contract’s data type and does not match the regex pattern, the hook fails.
check-model-columns-have-desc
What it doesEnsures that the model has columns with descriptions in the properties file (usually
schema.yml).When to use itYou want to make sure that all specified columns in the properties files (usually schema.yml) have some description. This hook does not validate if all database columns are also present in a properties file.--manifest: location of manifest.json file. Usually target/manifest.json. This file contains a full representation of dbt project. Default: target/manifest.json
Example
1 It means that you need to run
dbt parse before run this hook (dbt >= 1.5).2 It means that you need to run
dbt docs generate before run this hook.
How it works
- Hook takes all changed
ymlandSQLfiles. - The model name is obtained from the
SQLfile name. - The manifest is scanned for a model.
- Modified
ymlfiles are scanned for a model. - If any column in the found model does not contain a description, the hook fails.
- The description must be in either the yml file or the manifest.
run your model and then you delete column description from a properties file, the hook success since the description is still present in manifest.json.
check-model-has-all-columns
What it doesEnsures that all columns in the database are also specified in the properties file. (usually
schema.yml).When to use itYou want to make sure that you have all the database columns listed in the properties file, or that your properties file no longer contains deleted columns.--manifest: location of manifest.json file. Usually target/manifest.json. This file contains a full representation of dbt project. Default: target/manifest.json--catalog: location of catalog.json file. Usually target/catalog.json. dbt uses this file to render information like column types and table statistics into the docs site. In dbt-checkpoint is used for column operations. Default: target/catalog.json--exclude: Regex pattern to exclude files.
Example
1 It means that you need to run
dbt parse before run this hook (dbt >= 1.5).2 It means that you need to run
dbt docs generate before run this hook.
How it works
- Hook takes all changed
SQLfiles. - The model name is obtained from the
SQLfile name. - The manifest is scanned for a model.
- The catalog is scanned for a model.
- If there is any discrepancy between manifest and catalog models, the hook fails.
check-model-has-contract
What it doesChecks that model’s yaml has:When to use itWhen you want to force developers to define model contracts.
--manifest: location of manifest.json file. Usually target/manifest.json. This file contains a full representation of dbt project. Default: target/manifest.json--exclude: Regex pattern to exclude files.
Example
check-model-has-constraints
What it doesChecks that model’s yaml has specific constraints defined, eg:When to use itWhen you want to force developers to define model constraints.
--manifest: location of manifest.json file. Usually target/manifest.json. This file contains a full representation of dbt project. Default: target/manifest.json--constraints: JSON string escaped by single quotes --exclude: Regex pattern to exclude files.
Example
check-model-has-description
What it doesEnsures that the model has a description in the properties file (usually
schema.yml).When to use itYou want to make sure that all models have a description.--manifest: location of manifest.json file. Usually target/manifest.json. This file contains a full representation of dbt project. Default: target/manifest.json--exclude: Regex pattern to exclude files.
Example
1 It means that you need to run
dbt parse before run this hook (dbt >= 1.5).2 It means that you need to run
dbt docs generate before run this hook.
How it works
- Hook takes all changed
ymlandSQLfiles. - The model name is obtained from the
SQLfile name. - The manifest is scanned for a model.
- Modified
ymlfiles are scanned for a model. - If any model (from a manifest or
ymlfiles) does not have a description, the hook fails. - The model description must be in either the yml file or the manifest.
run your model and then you delete the description from a properties file, the hook success since the description is still present in manifest.json.
check-model-has-meta-keys
What it doesEnsures that the model has a list of valid meta keys. (usually
schema.yml).By default, it does not allow the model to have any other meta keys other than the ones required. An optional argument can be used to allow for extra keys.When to use itIf every model needs to have certain meta keys.--manifest: location of manifest.json file. Usually target/manifest.json. This file contains a full representation of dbt project. Default: target/manifest.json--meta-keys: list of the required keys in the meta part of the model.--allow-extra-keys: whether extra keys are allowed. Default: False.
Example
-- as the last argument. Otherwise pre-commit would not be able to separate a list of files with args.
Requirements
1 It means that you need to run
dbt parse before run this hook (dbt >= 1.5).2 It means that you need to run
dbt docs generate before run this hook.
How it works
- Hook takes all changed
ymlandSQLfiles. - The model name is obtained from the
SQLfile name. - The manifest is scanned for a model.
- Modified
ymlfiles are scanned for a model. - If any model (from a manifest or
ymlfiles) does not have specified meta keys, the hook fails. - The meta keys must be in either the yml file or the manifest.
run your model and then you delete meta keys from a properties file, the hook success since the meta keys is still present in manifest.json.
check-model-has-labels-keys
What it doesEnsures that the model has a list of valid labels keys. (usually
schema.yml).By default, it does not allow the model to have any other labels keys other than the ones required. An optional argument can be used to allow for extra keys.When to use itIf every model needs to have certain labels keys.--manifest: location of manifest.json file. Usually target/manifest.json. This file contains a full representation of dbt project. Default: target/manifest.json--labels-keys: list of the required keys in the labels part of the model.--allow-extra-keys: whether extra keys are allowed. Default: False.
Example
-- as the last argument. Otherwise pre-commit would not be able to separate a list of files with args.
Requirements
1 It means that you need to run
dbt parse before run this hook (dbt >= 1.5).2 It means that you need to run
dbt docs generate before run this hook.
How it works
- Hook takes all changed
ymlandSQLfiles. - The model name is obtained from the
SQLfile name. - The manifest is scanned for a model.
- Modified
ymlfiles are scanned for a model. - If any model (from a manifest or
ymlfiles) does not have specified labels keys, the hook fails. - The labels keys must be in either the yml file or the manifest.
run your model and then you delete labels keys from a properties file, the hook success since the labels keys is still present in manifest.json.
check-model-has-properties-file
What it doesEnsures that the model has a properties file (schema file).When to use itYou want to make sure that every model has a properties file.
--manifest: location of manifest.json file. Usually target/manifest.json. This file contains a full representation of dbt project. Default: target/manifest.jsonExample
1 It means that you need to run
dbt parse before run this hook (dbt >= 1.5).2 It means that you need to run
dbt docs generate before run this hook.
How it works
- Hook takes all changed
SQLfiles. - The model name is obtained from the
SQLfile name. - The manifest is scanned for a model.
- If any model does not have
patch_path, the hook fails.
dbt run or dbt compile), otherwise, this hook will fail.
check-model-has-tests-by-name
What it doesEnsures that the model has a number of tests of a certain name (e.g. data, unique).When to use itYou want to make sure that every model has certain tests.
--manifest: location of manifest.json file. Usually target/manifest.json. This file contains a full representation of dbt project. Default: target/manifest.json--tests: key-value pairs of test names. Key is the name of test and value is required minimal number of tests eg. —test unique=1 not_null=2 (do not put spaces before or after the = sign).--exclude: Regex pattern to exclude files.
Example
-- as the last argument. Otherwise pre-commit would not be able to separate a list of files with args.
Requirements
1 It means that you need to run
dbt parse before run this hook (dbt >= 1.5).2 It means that you need to run
dbt docs generate before run this hook.
How it works
- Hook takes all changed
SQLfiles. - The model name is obtained from the
SQLfile name. - The manifest is scanned for a model.
- If any model does not have the number of required tests, the hook fails.
check-model-has-tests-by-type
What it doesEnsures that the model has a number of tests of a certain type (data, schema).When to use itYou want to make sure that every model has certain tests.
--manifest: location of manifest.json file. Usually target/manifest.json. This file contains a full representation of dbt project. Default: target/manifest.json--tests: key-value pairs of test types. Key is the type of test (data or schema) and value is required eg. —test data=1 schema=2 (do not put spaces before or after the = sign).--exclude: Regex pattern to exclude files.
Example
-- as the last argument. Otherwise pre-commit would not be able to separate a list of files with args.
Requirements
1 It means that you need to run
dbt parse before run this hook (dbt >= 1.5).2 It means that you need to run
dbt docs generate before run this hook.
How it works
- Hook takes all changed
SQLfiles. - The model name is obtained from the
SQLfile name. - The manifest is scanned for a model.
- If any model does not have the number of required tests, the hook fails.
check-model-has-tests-by-group
What it doesEnsures that the model has a number of tests from a group of tests.When to use itYou want to make sure that every model has one (or more) of a group of eligible tests (e.g. a set of unique tests).
--manifest: location of manifest.json file. Usually target/manifest.json. This file contains a full representation of dbt project. Default: target/manifest.json--tests: list of test names.--test_cnt: number of tests required across test group.--exclude: Regex pattern to exclude files.
Example
-- as the last argument. Otherwise pre-commit would not be able to separate a list of files with args.
Requirements
1 It means that you need to run
dbt parse before run this hook (dbt >= 1.5).2 It means that you need to run
dbt docs generate before run this hook.
How it works
- Hook takes all changed
SQLfiles. - The model name is obtained from the
SQLfile name. - The manifest is scanned for a model.
- If any model does not have the number of required tests, the hook fails.
check-model-has-tests
What it doesEnsures that the model has a number of tests.When to use itYou want to make sure that every model was tested.
--manifest: location of manifest.json file. Usually target/manifest.json. This file contains a full representation of dbt project. Default: target/manifest.json--test-cnt: Minimum number of tests required.--exclude: Regex pattern to exclude files.
Example
-- as the last argument. Otherwise pre-commit would not be able to separate a list of files with args.
Requirements
1 It means that you need to run
dbt parse before run this hook (dbt >= 1.5).2 It means that you need to run
dbt docs generate before run this hook.
How it works
- Hook takes all changed
SQLfiles. - The model name is obtained from the
SQLfile name. - The manifest is scanned for a model.
- If any model does not have a number of required tests, the hook fails.
check-model-name-contract
What it doesCheck that model name abides to a contract (similar to
check-column-name-contract). A contract consists of a regex pattern.When to use itYou want to make sure your model names follow a naming convention (e.g., staging models start with a stg_ prefix).--pattern: Regex pattern to match model names.--exclude: Regex pattern to exclude files.
Example
1 It means that you need to run
dbt parse before run this hook (dbt >= 1.5).2 It means that you need to run
dbt docs generate before run this hook.
How it works
- Hook takes all changed
SQLfiles. - The model name is obtained from the
SQLfile name. - The catalog is scanned for a model.
- If any model does not match the regex pattern, the hook fails.
check-model-parents-and-childs
What it doesEnsures the model has a specific number (max/min) of parents or/and childs.When to use itYou want to find orphaned models (empty file, hard-coded reference, etc.). Or you want to make sure that every model is used somewhere so you are not e.g. materializing unused tables.
--manifest: location of manifest.json file. Usually target/manifest.json. This file contains a full representation of dbt project. Default: target/manifest.json--min-parent-cnt: Minimal number of parent sources and models. --max-parent-cnt: Maximal number of parent sources and models. --min-child-cnt: Minimal number of child models. --max-child-cnt: Maximal number of child models.
Example
-- as the last argument. Otherwise pre-commit would not be able to separate a list of files with args.
Requirements
1 It means that you need to run
dbt parse before run this hook (dbt >= 1.5).2 It means that you need to run
dbt docs generate before run this hook.
How it works
- Hook takes all changed
SQLfiles. - The model name is obtained from the
SQLfile name. - The manifest is scanned for a parent and child models.
- If any model does not have a number of required parents/childs, the hook fails.
check-model-parents-database
What it doesEnsures the parent models or sources are from certain database.When to use itYou want to be sure that certain models are using only models from specified database(s).
--manifest: location of manifest.json file. Usually target/manifest.json. This file contains a full representation of dbt project. Default: target/manifest.json--whitelist: list of allowed databases. --blacklist: list of disabled databases. --exclude: Regex pattern to exclude files.
Example
-- as the last argument. Otherwise pre-commit would not be able to separate a list of files with args.
Requirements
1 It means that you need to run
dbt parse before run this hook (dbt >= 1.5).2 It means that you need to run
dbt docs generate before run this hook.
How it works
- Hook takes all changed
SQLfiles. - The model name is obtained from the
SQLfile name. - The manifest is scanned for a parent models/sources.
- If any parent model does not have allowed or has disabled databases, the hook fails.
check-model-parents-name-prefix
What it doesEnsures the parent model names have a certain prefix.When to use itYou want to be sure that certain models are using only parent models with a specified prefix
--manifest: location of manifest.json file. Usually target/manifest.json. This file contains a full representation of dbt project. Default: target/manifest.json--whitelist: list of allowed prefixes. --blacklist: list of non-allowed prefixes. --exclude: Regex pattern to exclude files.
Example
-- as the last argument. Otherwise pre-commit would not be able to separate a list of files with args.
Requirements
1 It means that you need to run
dbt parse before run this hook (dbt >= 1.5).2 It means that you need to run
dbt docs generate before run this hook.
How it works
- Hook takes all changed
SQLfiles. - The model name is obtained from the
SQLfile name. - The manifest is scanned for a parent models/sources.
- If any parent model does not have allowed or has disabled databases, the hook fails.
check-model-parents-schema
What it doesEnsures the parent models or sources are from certain schema.When to use itYou want to be sure that certain models are using only models from specified schema(s).
--manifest: location of manifest.json file. Usually target/manifest.json. This file contains a full representation of dbt project. Default: target/manifest.json--whitelist: list of allowed schemas. --blacklist: list of disabled schemas.
Example
-- as the last argument. Otherwise pre-commit would not be able to separate a list of files with args.
Requirements
1 It means that you need to run
dbt parse before run this hook (dbt >= 1.5).2 It means that you need to run
dbt docs generate before run this hook.
How it works
- Hook takes all changed
SQLfiles. - The model name is obtained from the
SQLfile name. - The manifest is scanned for a parent models/sources.
- If any parent model does not have allowed or has disabled schemas, the hook fails.
check-model-tags
What it doesEnsures that the model has only valid tags from the provided list.When to use itMake sure you did not typo in tags.
--manifest: location of manifest.json file. Usually target/manifest.json. This file contains a full representation of dbt project. Default: target/manifest.json--tags: A list of tags that models can have. --exclude: Regex pattern to exclude files.
Example
-- as the last argument. Otherwise pre-commit would not be able to separate a list of files with args.
Requirements
1 It means that you need to run
dbt parse before run this hook (dbt >= 1.5).2 It means that you need to run
dbt docs generate before run this hook.
How it works
- Hook takes all changed
SQLfiles. - The model name is obtained from the
SQLfile name. - The manifest is scanned for a model.
- If any model has different tags than specified, the hook fails.
check-model-materialization-by-childs
What it doesChecks the model materialization by a given threshold of child models. All models with less child models then the treshold should be materialized as views (or ephemerals), all the rest as tables or incrementals.When to use itMake sure to increase the efficiency within your dbt run and make use of good materialization choices.
--manifest: location of manifest.json file. Usually target/manifest.json. This file contains a full representation of dbt project. Default: target/manifest.json--threshold-childs: An integer threshold of the number of child models.
Example
1 It means that you need to run
dbt parse before run this hook (dbt >= 1.5).2 It means that you need to run
dbt docs generate before run this hook.