Open jaklan opened 2 months ago
Thanks for reporting this @jaklan !
I was able to reproduce what you reported. But I didn't need to use a custom generic test. Using a standard out-of-the-box test like not_null
was sufficient. Details in the "reprex" section below.
I was also able to get this to behave correctly by:
project_b.model_a1
,--no-partial-parse
when doing a dbt list
(or dbt parse
, etc) to recreate the partial parsing fileproject_b.model_a1
,That's not a sustainable workaround! But it did give me a good manifest.json
that I could compare with a bad one:
The key differences were in the parent_map
and child_map
sections.
"parent_map": {
"model.package_a.model_a1": [],
"test.package_a.sample_test_model_a1_id.ff32e12b9f": [
"model.package_a.model_a1"
],
"model.package_b.model_a1": []
},
"child_map": {
"model.package_a.model_a1": [
"test.package_a.sample_test_model_a1_id.ff32e12b9f"
],
"test.package_a.sample_test_model_a1_id.ff32e12b9f": [],
"model.package_b.model_a1": []
},
"parent_map": {
"model.package_b.model_a1": [],
"model.package_a.model_a1": [],
"test.package_a.sample_test_model_a1_id.ff32e12b9f": [
"model.package_b.model_a1"
]
},
"child_map": {
"model.package_b.model_a1": [
"test.package_a.sample_test_model_a1_id.ff32e12b9f"
],
"model.package_a.model_a1": [],
"test.package_a.sample_test_model_a1_id.ff32e12b9f": []
},
Basically, when parsing from scratch, it is favoring the model name from the root package (package_b
) and incorrectly linking it to the upstream test definition (from package_a
). š„
@dbeatty10 thanks for verification!
Is this a new bug in dbt-core?
Current Behavior
When you install a package containing models with specified tests as your project dependency, and create a model in the current package with the same name as one of those models - tests for the upstream model will be triggered also for the new one (even if
package:this
selector is used) and can causedbt test
/dbt build
failures.Expected Behavior
Tests are not propagated to downstream packages, especially when using
package:this
selector.Steps To Reproduce
package_a
model_a
sample_test
schema.yml
like:models:
package_b
model_a
package_a
as a dependencyschema.yml
dbt ls -s "model_a1"
:dbt ls -s "package:this,model_a1"
:dbt test -s "package:this,model_a1"
:I have also run
{{ print(model) }}
inside the test - and can confirm it's triggered for the model from the current package, not the upstream one.Environment
Which database adapter are you using with dbt?
redshift, duckdb (doesn't matter)