-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CT-2787] [Bug] dbt is too aggressive about preventing contracted changes during CI #8028
Comments
Agree with Joel's suggestions, but I think in I think in @jelstongreen's use case (ie the contract is updated also) we might consider no warning at all, so we compare against the current contract not the old? |
Thanks @joellabes for raising the issues and both for comments. I would agree with @jaypeedevlin in that if the contract has been updated then verification should be against the new contract rather than the old one when using |
@joellabes @jelstongreen @jaypeedevlin Good conversation! Thanks for opening the issue to track it. Today, dbt performs two contract checks:
The former check always happens using the newest version of the contract. In the scenario we're describing, the first checks passes. It's the second check that we're interested in here. To JPD's point about I do hear this point from Joel:
I agree it's odd to have the check happen during selection syntax. We could do it instead during "deferral", or as soon as you pass a To JEG's point: I see how you want a way to override dbt's error ("I know what I'm doing") without strictly requiring a new model version. When we'd imagined this workflow a few months ago, @MichelleArk and I were imagining that this should happen rarely, but not never—perhaps some production issue requires immediate action—and so you'd "merge on red" (failing CI). I'm hesitant to downgrade this from error to warning, because it risks getting lost among other warnings, makes it harder to surface, and CI checks tend to yield binary results: ✅ or ❌ . I can see the argument in favor of keeping this as an error by default, but giving users a way to downgrade this to a warning; we just don't lack an existing pattern to do that, à la One idea: You could bump the model's version, without creating multiple versions. That's effectively what you're doing anyway, by updating the contract with a breaking change, and saying that there won't be any old version sticking around for a migration window. (I'm going to try this out right now and report back.) |
-- models/my_model.sql
select 1 as id # models/my_model.yml
models:
- name: my_model
config:
contract: {enforced: true}
columns:
- name: id
data_type: integer
- name: this_column_will_be_removed
data_type: boolean The first contract check (1) succeeds when I run What starts failing is the second check (2), which detects a breaking change in a stateful comparison:
I can get that check passing by "bumping" the version of the model (even if it was previously not versioned). models:
- name: my_model
config:
contract: {enforced: true}
columns:
- name: id
data_type: integer
versions:
- v: 2 Things that make this work seamlessly:
(Note: This should also work if the model was previously versioned, and we just bump from |
I quite like this! It's a "leave me alone I know what I'm doing" flag, but it's in the right place - you can add it before going through the CI flow instead of getting an error and then temporarily editing the |
I don't quite like the idea of requiring a version change in order to work around this. Our team is not yet ready to deal with versions. We wanted to to get contracts going first, get comfortable with those, and then later start incorporating versions. It's just another layer of complexity to have to deal with. I do like the idea of being able to optionally just warn on contract violations. However, I'm still stuck on how I'd be able to work with that in CI. If I were doing my own CI (instead of SlimCI), I might think about setting the warn flag if the commit message contained some string indicating I didn't want to enforce the contract (or I wanted to change it). Feels hacky to me, but it might work. With dbt-cloud and SlimCI I don't see how I'd be able to do that without changing the CI job to temporarily do a warn-only. However, that would apply to any other pull requests that might be initiated at the time, which wouldn't work well for larger teams. |
My team is also not ready to use explicit versioning for our model changes but we want to be able to enforce model contracts based on our defined schema. The contracts are also useful internally as part of the development cycle because it enforces that the model we are writing matches our expected output shape. When we make a change to the schema we are explicitly stating that the contract is changing and it is unintuitive that we would compare the new model against the old contract. During rapid iteration phases of a model having to bump the version every single time that a column is renamed or a data type is changed is highly disruptive and makes the contracts feature more of a harm than a good. I understand the purpose of explicit versioning when providing guarantees for external use. It is great when you want to enforce an external contract and provide guarantees but that is distinct from shape enforcement. In my view, an error like this should be raised only if an explicit version number has been specified for the model and the contract has changed but the version number has not. This is entangling shape-enforcement with version enforcement which feel like two distinct features. Edit: Added more context |
@gnilrets @rchui Thanks both for sharing your perspectives, and making some really compelling points! Here's what I'm thinking:
Things I like about this:
Update: Opened as implementation ticket: #8384 |
I'm closing this as a duplicate, since we are tracking the implementation on #8384 Thanks for all of your input :) |
Unfortunately I'm only catching up to this discussion after implementation, but I wonder if there's a better approach here. With the current option Something like having 3 options for |
Is this a new bug in dbt-core?
Current Behavior
Slack discussion
When using dbt alongside
state:modified
, any breaking changes to the contract are rejected as an error.To summarise the thread:
dealcontract has been altered to accurately reflect the new statestate:modified
is only used in CI contextsExpected Behavior
I think
ContractBreakingChangeError
should instead be a warning which can be escalated in CI contexts with--warn-error
or--warn-error-options
. This would solve all three of the above issues:If we feel strongly that this is almost always an error but should be allowed to be ignored, I guess I would also settle for the inverse: some way to downgrade the errors to warnings.
Steps To Reproduce
dbt compile
dbt run -s state:modified --state path/to/artifacts
Relevant log output
Environment
Which database adapter are you using with dbt?
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: