Open graciegoheen opened 6 months ago
Take a look at the migration path for column level constraints. @MichelleArk Can you add a link?
Add a snowplow event to track how often this happens as part of the work here.
To make this backward-compatible, we could:
or
Just wanted to comment on this one. There's been lots of development on adding more constraint support and now custom constraints. However that's all blocked by requiring a contract even though many target systems will allow adding constraints through later alter statements (usually failing if the constraint isn't valid for existing data). It would still be really great to be able to apply these constraints outside a contract.
I'd suggest push it to the adapters to determine if they can support constraints through an alter vs requiring a contract up front.
Completely agree with this. Constraints and column definitions should be separate. Columns can and already are pulled based on the model .sql when not defined. I shouldn't have to explicitly define 100+ columns just so that I can have a composite primary key on two of them. Yes, I can have a test that validates the constraint instead of having it on the database object, but it's still better to have it as table metadata so that users querying the data have the information they need.
Is this your first time submitting a feature request?
Describe the feature
From @kmarq in https://github.com/dbt-labs/dbt-core/issues/10195:
Recreated some previous testing of constraints. If you define a primary_key constraint on a column
The constraint shows up in the model.columns
whether the contract enforcement is true or false.
If you define a composite primary_key on the model
Then in the model.constraints you will see this ONLY if contract enforcement is true:
compared to false:
It looks like we're parsing model-level constraints (populating model['constraints']) only if contract enforcement is enabled.
Acceptance Criteria
Who will this benefit?
No response
Are you interested in contributing this feature?
No response
Anything else?
No response