dbt-checkpoint
dbt-checkpoint copied to clipboard
Check that a column name is a certain data type
Describe the feature you'd like I would love to enforce rules in the warehouse that if a column is called "LOAD_TIMESTAMP" it has to be TIMESTAMP_NTZ data type.
Additional context Just good to apply rules for a large team.
@culpgrant the check-name-contract should do the trick for this! Try this hook:
- id: check-column-name-contract
args: [--pattern, "LOAD_TIMESTAMP", --dtype, TIMESTAMP_NTZ]
Closing this but feel free to reopen if this doesn't solve your case.
Sorry, I spoke too soon! This hook works both ways for the contract: it will check to make sure that every occurrence of the pattern is enforced as the data type, and that every occurrence of the data type is enforced as the pattern.
Having said that, it could be good to think about an enhancement to that current hook to allow for one-way contracts (e.g. all occurrences of the pattern follow the data type, but not all occurrences of the data type follow the pattern).
I'll reopen this issue and create a new enhancement for that with a bit more detail.
The larger enhancement request has been added here: #121.