-
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
Run tests IFF all first-order parents are selected #2891
Comments
I just ran into this in the following scenario for a slim CI build: I have models I also have a relationship test defined on model B that points to A. I touch model A, so my slim CI build becomes This fails since dbt selects the relationship test defined on model B because the relationship test depends on both A and B. dbt is selecting the test if ANY parent is selected, while I was looking for it run the test if ALL parents were selected. Shouldn't running the test when ALL dependent nodes are selected be the default behaviour? I would much prefer to have this be the default and have a flag for the current behaviour rather than the other way around. Are there some use-cases I'm missing that this would completely break? Workaround Jeremy pointed out that I can use the |
@balmasi Thanks for the comment! A couple of thoughts here: Slim CI: The reason we added support for In my view, relationships tests don't square with CI builds. You're frequently working with a limited subset of data, whether that's a date cutoff or a random sample. The other three builtin dbt tests—
I take your point here, and I'm sympathetic to this argument. This is something we've considered changing in the default behavior (#1827, #2132); I'm still figuring out how we should implement it in practice. This isn't how selection works for other resource types: If you Granted, test selection is different from other resource selection because of the "magic jump" baked into it: when I test What's the appeal of that "magic jump"? It enables consistency of syntax between In that world, if we had a relationships test between
Today, all of the above select and execute that relationships test. In the first case, the intuitive syntax of the "magic jump" actually backfires, results in the unintuitive case you've encountered. @drewbanin I'd be curious to get your thoughts here! I started this comment ready to say that we shouldn't do this... in the course of writing it out, I've managed to convince myself that it might just manage to thread the needle the way we'd want. |
+1-ing this. In our use case, we need to do partial dbt runs in production in a separate environment due to sensitive (source) patient data in that environment. But we’d like to share the same models, so we have a monolithic project. So, some models just don’t run in this We’d like to follow a blue/green deployment and test before we deploy our data, but the selection of irrelevant relationship tests prevents this. (more on whether this is truly irrelevant below) So, to recap: we run I’m torn on whether this is fundamentally problematic or just requires configurability. If there’s a relationship test, testing model
I don’t think
The only two workarounds we’ve found:
|
Describe the feature
See prior discussion: #1827, #2132, misc
state:modified
conversationsRun a test only if all first-order parents are included in the selection criteria. This would be most immediately relevant for:
relationships
testsThis would also handle cases where a schema test has a property (
tag:
,state:
) that its one parent model does not have. Since its single parent would not be included in the selection criteria, given the proposed condition, the test should not run.Describe alternatives you've considered
--all-parents
) to enable this?Who will this benefit?
Users who want finer-grained control over which tests they're running, especially:
The text was updated successfully, but these errors were encountered: