-
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
Relation doesn't exist for dbt test after dbt run -m state:modified
if the test was modified but the model wasn't
#2833
Comments
Hey @joellabes, you're asking the $64k question here. @huntdm07 and I had a lengthy thread about just this in slack yesterday. My initial hope had been to resolve this via deferral for tests (#2701). If there's a model you didn't build, no worries, dbt will execute your new/modified test query against the production (deferred) version of that model instead. This turned out to be way trickier to implement than we expected, based on how resource selection works—how can dbt determine if a model is in the selection criteria or should be deferred, when in actuality Instead, I've placed my hopes elsewhere: given all the clever node selection syntax available in v0.18, we should be able to find a way to make this work. There's some good discussion in #2704 about what that looks like today vs. how it could look in the future. Today, we can write selection syntax to ensure that the first-order unmodified parent of a modified test is always built in a CI run. In a dbt Cloud job definition (i.e. without dbt run -m state:modified 1+state:modified,1+test_type:schema 1+state:modified,1+test_type:data
dbt test -m state:modified "Run all modified models, plus any models that are first-order parents of modified tests." This is a safe-not-sorry approach: it's likely to include a few more models than strictly necessary—i.e. unmodified models that are first-order parents of modified models and also have unmodified tests—but it should work. Longer term, the answer here looks like:
That's my spiel, and I appreciate you opening this issue because it forced me to write it down in one place. So... whatcha think? |
This is how I thought it worked - I must have read that proposal at some point and not caught up with all the gotchas that led to it being put aside. All good! I don't follow all of the backstory of Jake's proposal in #2704, but it implies that there's some baggage where the dbt test selectors magically expand to do what people mean, not what they strictly typed. And as with all magic it's hard to override it if you want something else?
Right now, I think I'm happy to sit back and trust y'all to make a good decision! I haven't got enough context to add much of value one way or the other. The (admittedly verbose) selector you've got above acts as a good workaround for now, so thanks for that! |
That's right! This is now documented (prerelease) as a known caveat to |
Describe the bug
Our Slim CI job runs
(there are some additional exclusions to the
dbt test
arg, but they're not relevant here)When I added another value to an accepted_values test, dbt identified that the test needed to be run, but it hadn't built the model during
dbt run
so I got this errorSteps To Reproduce
to
and do
Expected behavior
The test to pass, because all values in the column are accepted
Screenshots and log output
dbt run debug.log
dbt run console.log
dbt test console.log
dbt test debug.log
System information
Which database are you using dbt with?
The output of
dbt --version
:The operating system you're using:
dbt Cloud
The output of
python --version
:The text was updated successfully, but these errors were encountered: