You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In #6271, constraints: List[str] and constraints_check: str are optional column configs that configure column-level constraints and row-level checks respectively.
classConstraintOption(StrEnum):
check="check"not_null="not_null"unique="unique"primary_key="primary_key"foreign_key="foreign_key"custom="custom"# I have no idea -- but let's leave it open for the wacky & wild data platforms out thereColumnLevelConstraint:
type: ConstraintOptionname: Optional[str]
warn_unenforced: bool=True# raise a warning if this constraint is not enforced by this data platform (but will still be included in templated DDL)warn_unsupported: bool=True# raise a warning if this constraint is not supported by this data platform (and will be excluded from templated DDL)expression: Optional[str] # free for all. required if constraint is 'check' or 'foreign_key' -- can we validate via post-init ?# additional properties allowed: yes! there are going to be lots of constraint-specific and platform-specific shenanigans# the same, with an added 'columns' attribute (which isn't needed when the constraint is defined for one column)ModelLevelConstraint(ColumnLevelConstraint):
columns: List[str]
constraints is an optional attribute at both the model level and the column level
If constraints is set a the model level, it should be a model-level attribute, not a "config." This means it isn't settable in {{ config() }} or in dbt_project.yml, and that's okay.
warn_unenforced & warn_unsupported could alternatively be Optional[bool], and flipped/renamed to ignore_warning_unenforced & ignore_warning_unsupported, so that the data is only included when it's a non-default value
This will require changes in adapter macros to obtain constraints information from the new data structure to build constraint ddl.
The text was updated successfully, but these errors were encountered:
github-actionsbot
changed the title
Unify constraints and constraints_check configs
[CT-2198] Unify constraints and constraints_check configs
Feb 27, 2023
Refinement discussion: #6750
In #6271, constraints: List[str] and constraints_check: str are optional column configs that configure column-level constraints and row-level checks respectively.
Current data structure
Proposed data structure
Constraint
is a new object type. Pseudo code:Notes:
constraints
is an optional attribute at both the model level and the column levelconstraints
is set a the model level, it should be a model-level attribute, not a "config." This means it isn't settable in{{ config() }}
or indbt_project.yml
, and that's okay.warn_unenforced
&warn_unsupported
could alternatively beOptional[bool]
, and flipped/renamed toignore_warning_unenforced
&ignore_warning_unsupported
, so that the data is only included when it's a non-default valueThe text was updated successfully, but these errors were encountered: