Naming#
Note
The below checks require catalog.json to be present.
Checks related to column naming conventions.
Functions:
| Name | Description |
|---|---|
check_column_name_complies_to_column_type |
Columns with the specified regexp naming pattern must have data types that comply to the specified regexp pattern or list of data types. |
check_column_names |
Columns must have a name that matches the supplied regex. |
check_column_name_complies_to_column_type
#
Columns with the specified regexp naming pattern must have data types that comply to the specified regexp pattern or list of data types.
Note: One of type_pattern or types must be specified.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
column_name_pattern
|
str
|
Regex pattern to match the model name. |
required |
type_pattern
|
str | None
|
Regex pattern to match the data types. |
None
|
types
|
list[str] | None
|
List of data types to check. |
None
|
Receives at execution time:
| Name | Type | Description |
|---|---|---|
catalog_node |
CatalogNodeEntry
|
The CatalogNodeEntry object to check. |
Other Parameters (passed via config file):
| Name | Type | Description |
|---|---|---|
description |
str | None
|
Description of what the check does and why it is implemented. |
exclude |
str | None
|
Regex pattern to match the model path. Model paths that match the pattern will not be checked. |
include |
str | None
|
Regex pattern to match the model path. Only model paths that match the pattern will be checked. |
severity |
Literal[error, warn] | None
|
Severity level of the check. Default: |
Example(s):
catalog_checks:
# DATE columns must end with "_date"
- name: check_column_name_complies_to_column_type
column_name_pattern: .*_date$
types:
- DATE
catalog_checks:
# BOOLEAN columns must start with "is_"
- name: check_column_name_complies_to_column_type
column_name_pattern: ^is_.*
types:
- BOOLEAN
catalog_checks:
# Columns of all types must consist of lowercase letters and underscores. Note that the specified types depend on the underlying database.
- name: check_column_name_complies_to_column_type
column_name_pattern: ^[a-z_]*$
types:
- BIGINT
- BOOLEAN
- DATE
- DOUBLE
- INTEGER
- VARCHAR
catalog_checks:
# No STRUCT data types permitted.
- name: check_column_name_complies_to_column_type
column_name_pattern: ^[a-z_]*$
type_pattern: ^(?!STRUCT)
Source code in src/dbt_bouncer/checks/catalog/columns/naming.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
check_column_names
#
Columns must have a name that matches the supplied regex.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
column_name_pattern
|
str
|
Regexp the column name must match. |
required |
Receives at execution time:
| Name | Type | Description |
|---|---|---|
catalog_node |
CatalogNodeEntry
|
The CatalogNodeEntry object to check. |
Other Parameters (passed via config file):
| Name | Type | Description |
|---|---|---|
description |
str | None
|
Description of what the check does and why it is implemented. |
exclude |
str | None
|
Regex pattern to match the model path. Model paths that match the pattern will not be checked. |
include |
str | None
|
Regex pattern to match the model path. Only model paths that match the pattern will be checked. |
materialization |
Literal[ephemeral, incremental, table, view] | None
|
Limit check to models with the specified materialization. |
severity |
Literal[error, warn] | None
|
Severity level of the check. Default: |
Example(s):
catalog_checks:
- name: check_column_names
column_name_pattern: [a-z_] # Lowercase only, underscores allowed